{"id":15393014,"url":"https://github.com/shgysk8zer0/node-http","last_synced_at":"2025-04-15T23:33:55.225Z","repository":{"id":196213412,"uuid":"693838436","full_name":"shgysk8zer0/node-http","owner":"shgysk8zer0","description":"A JavaScript library that provides various utilities for working with HTTP","archived":false,"fork":false,"pushed_at":"2025-02-20T18:22:06.000Z","size":320,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T17:44:20.055Z","etag":null,"topics":["form-data","http-error","http-status","node"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@shgysk8zer0/http","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shgysk8zer0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"shgysk8zer0","liberapay":"shgysk8zer0"}},"created_at":"2023-09-19T20:17:21.000Z","updated_at":"2025-02-20T18:22:07.000Z","dependencies_parsed_at":"2024-01-18T17:23:43.454Z","dependency_job_id":"9beb40a4-6d58-4681-8c9d-13aa8a784036","html_url":"https://github.com/shgysk8zer0/node-http","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.36363636363636365","last_synced_commit":"16ef7cd929f91ba6677713cb1a23705bbaf7e133"},"previous_names":["shgysk8zer0/node-http"],"tags_count":6,"template":false,"template_full_name":"shgysk8zer0/npm-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Fnode-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Fnode-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Fnode-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Fnode-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shgysk8zer0","download_url":"https://codeload.github.com/shgysk8zer0/node-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241226831,"owners_count":19930488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["form-data","http-error","http-status","node"],"created_at":"2024-10-01T15:17:03.901Z","updated_at":"2025-02-28T20:31:44.681Z","avatar_url":"https://github.com/shgysk8zer0.png","language":"JavaScript","readme":"# `@shgysk8zer0/http`\nA JavaScript library that provides various utilities for working with HTTP\n\n[![CodeQL](https://github.com/shgysk8zer0/node-http/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/shgysk8zer0/http/actions/workflows/codeql-analysis.yml)\n![Node CI](https://github.com/shgysk8zer0/node-http/workflows/Node%20CI/badge.svg)\n![Lint Code Base](https://github.com/shgysk8zer0/node-http/workflows/Lint%20Code%20Base/badge.svg)\n\n[![GitHub license](https://img.shields.io/github/license/shgysk8zer0/node-http.svg)](https://github.com/shgysk8zer0/node-http/blob/master/LICENSE)\n[![GitHub last commit](https://img.shields.io/github/last-commit/shgysk8zer0/node-http.svg)](https://github.com/shgysk8zer0/node-http/commits/master)\n[![GitHub release](https://img.shields.io/github/release/shgysk8zer0/node-http?logo=github)](https://github.com/shgysk8zer0/node-http/releases)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/shgysk8zer0?logo=github)](https://github.com/sponsors/shgysk8zer0)\n\n[![npm](https://img.shields.io/npm/v/@shgysk8zer0/http)](https://www.npmjs.com/package/@shgysk8zer0/http)\n![node-current](https://img.shields.io/node/v/@shgysk8zer0/http)\n![npm bundle size gzipped](https://img.shields.io/bundlephobia/minzip/@shgysk8zer0/http)\n[![npm](https://img.shields.io/npm/dw/@shgysk8zer0/http?logo=npm)](https://www.npmjs.com/package/@shgysk8zer0/http)\n\n[![GitHub followers](https://img.shields.io/github/followers/shgysk8zer0.svg?style=social)](https://github.com/shgysk8zer0)\n![GitHub forks](https://img.shields.io/github/forks/shgysk8zer0/node-http.svg?style=social)\n![GitHub stars](https://img.shields.io/github/stars/shgysk8zer0/node-http.svg?style=social)\n[![Twitter Follow](https://img.shields.io/twitter/follow/shgysk8zer0.svg?style=social)](https://twitter.com/shgysk8zer0)\n\n[![Donate using Liberapay](https://img.shields.io/liberapay/receives/shgysk8zer0.svg?logo=liberapay)](https://liberapay.com/shgysk8zer0/donate \"Donate using Liberapay\")\n- - -\n\n- [Code of Conduct](./.github/CODE_OF_CONDUCT.md)\n- [Contributing](./.github/CONTRIBUTING.md)\n\u003c!-- - [Security Policy](./.github/SECURITY.md) --\u003e\n\n# Key Features\n\n- Exported constants for common HTTP status codes, such as `ok` for 200.\n- An extended `HTTPError` class that inherits from Error.\n- Useful polyfills, including an extended `File` object (derived from `Blob`) and `URL.canParse()` for URL validation.\n- A set of constants for commonly used Content-Types (from `@shgysk8zer0/consts`).\n- A versatile `openLink()` function compatible with various JavaScript environments.\n- A `Cookie` class for working with HTTP cookies, enabling easy cookie creation and management.\n\n\u003e [!WARNING]\n\u003e Parsing of form data uses regex which has been reported as [vulnerable to ReDoS](https://github.com/shgysk8zer0/node-http/issues/2)\n\u003e attacks. `parseMultipartFormData()` is deprecated and will be removed in an\n\u003e upcoming release. Instead, in node \u003e 18 you can use `new Request(body, { headers }).formData()`.\n\n## Installation\n\n### NPM Installation\n\n```bash\nnpm i @shgysk8zer0/http\n```\n\n### NPM Imports\n```js\nimport { HTTPError } from 'shgysk8zer0/http@shgysk8zer0/http/error.js';\nimport { NOT_IMPLEMENTED, INTERNAL_SERVER_ERROR } from 'shgysk8zer0/http@shgysk8zer0/http/status.js';\nimport { JSON } from 'shgysk8zer0/http@shgysk8zer0/http/types.js';\nimport { Cookie } from 'shgysk8zer0/http@shgysk8zer0/http/cookie.js';\n```\n\n### Alternative `import`s\n\nThis package is available on [unpkg.com](https://unpkg.com/browse/@shgys8zer0/http/) as a collection of modules, making it easily accessible for browser-based projects.\nIt is designed to be versatile and is not limited to a specific Node.js environment, ensuring compatibility across various platforms.\n\n```js\nimport { HTTPError } from 'https://unpkg.com/@shgysk8zer0/http/error.js';\nimport { NOT_IMPLEMENTED, INTERNAL_SERVER_ERROR } from 'https://unpkg.com/@shgysk8zer0/http/status.js';\nimport { JSON } from 'https://unpkg.com/@shgysk8zer0/http/types.js';\nimport { Cookie } from 'https://unpkg.com/@shgysk8zer0/http/cookie.js';\n```\n\n### Example Code\n\n```js\nexport async function handler() {\n  try {\n    const error = new HTTPError('Not implemented.', {\n      status: NOT_IMPLEMENTED,\n      cause: new Error('I have not done this yet...'),\n    });\n    \n    throw err;\n  } catch (err) {\n    if (err instanceof HTTPError) { // Error has an HTTP status \u0026 message for use by client\n      return Response.json(error, {\n        status: error.status,\n        headers: new Headers({\n          'Content-Type': JSON,\n          'Set-Cookie': new Cookie('uid', crypto.randomUUID(), {\n            domain: 'example.com',\n            path: '/foo',\n            maxAge: 86_400_000,\n            sameSite: 'Strict',\n            httpOnly: true,\n            partitioned: true,\n          })\n        }),\n      });  \n    } else { // It is not an HTTPError and may contain sensitive into\n      return Response.json({\n        error: {\n          messsage: 'Something broke :(',\n          status: INTERNAL_SERVER_ERROR,\n        }\n      }, { status: INTERNAL_SERVER_ERROR });\n    }\n  }  \n}\n```\n","funding_links":["https://github.com/sponsors/shgysk8zer0","https://liberapay.com/shgysk8zer0","https://liberapay.com/shgysk8zer0/donate"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshgysk8zer0%2Fnode-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshgysk8zer0%2Fnode-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshgysk8zer0%2Fnode-http/lists"}