{"id":25566534,"url":"https://github.com/pdmlab/http-problem-details","last_synced_at":"2025-04-12T17:44:10.080Z","repository":{"id":34740053,"uuid":"181746958","full_name":"PDMLab/http-problem-details","owner":"PDMLab","description":"This library implements HTTP Problem details (RFC 7807) for HTTP APIs build with Node.js.","archived":false,"fork":false,"pushed_at":"2025-01-23T23:03:26.000Z","size":1263,"stargazers_count":48,"open_issues_count":7,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T20:11:07.705Z","etag":null,"topics":["error-messages","hateoas","hateoas-library","hateoas-response","http","node","nodejs","rest","rfc-7807"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/http-problem-details","language":"TypeScript","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/PDMLab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-16T18:41:40.000Z","updated_at":"2025-01-23T23:02:31.000Z","dependencies_parsed_at":"2025-02-20T22:33:08.405Z","dependency_job_id":"727ff490-29a2-4213-a7f1-b345251f5d8c","html_url":"https://github.com/PDMLab/http-problem-details","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PDMLab%2Fhttp-problem-details","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PDMLab%2Fhttp-problem-details/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PDMLab%2Fhttp-problem-details/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PDMLab%2Fhttp-problem-details/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PDMLab","download_url":"https://codeload.github.com/PDMLab/http-problem-details/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248609265,"owners_count":21132880,"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":["error-messages","hateoas","hateoas-library","hateoas-response","http","node","nodejs","rest","rfc-7807"],"created_at":"2025-02-20T22:33:03.645Z","updated_at":"2025-04-12T17:44:10.039Z","avatar_url":"https://github.com/PDMLab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) [![Join the chat at https://gitter.im/pdmlab/http-problem-details](https://badges.gitter.im/pdmlab/http-problem-details.svg)](https://gitter.im/pdmlab/http-problem-details?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n# HTTP Problem Details (RFC 7807) for Node.js\n\nThis library implements HTTP Problem details (RFC 7807) for HTTP APIs.\n\n## Installation\n\n```\nnpm install http-problem-details\n```\n\nor\n\n```\nyarn add http-problem-details\n```\n\n## Usage\n\n`http-problem-details` current supports these options:\n\n* `type` (string) - A URI reference [[RFC3986](https://tools.ietf.org/html/rfc3986)] that identifies the problem type.\n* `title` (string) - A short, human-readable summary of the problem type.\n* `status` (number) - The HTTP status code ([[RFC7231], Section 6](https://tools.ietf.org/html/rfc7231#section-6)) generated by the origin server for this occurrence of the problem. If only `status` is provided `type` will be set to `about:blank` and `title` will be become the reason phrase as of the HTTP spec, e.g. \"Not Found\" if `status` is `404`.\n* `instance` (string) - A URI reference that identifies the specific occurrence of the problem.\n* Extension Members - Provide additional information.\n\n`type` and `instance` are validated to be valid URIs and will throw errors if not.\n\n### Example\n\nTo generate this `problem+json` result\n\n```json\n{\n    \"type\": \"https://example.com/probs/out-of-credit\",\n    \"title\": \"You do not have enough credit.\",\n    \"detail\": \"Your current balance is 30, but that costs 50.\",\n    \"instance\": \"/account/12345/msgs/abc\",\n    \"status\": 400\n}\n```\n\nthis code is required:\n\n```javascript\nconst ProblemDocument = require('http-problem-details').ProblemDocument;\n\nconst doc = new ProblemDocument({\n  type: 'https://example.com/probs/out-of-credit',\n  title: 'You do not have enough credit.',\n  detail: 'Your current balance is 30, but that costs 50.',\n  instance: '/account/12345/msgs/abc',\n  status: 400\n});\n```\n\n### Example with Extension Members\n\nTo generate this `problem+json` result\n\n```json\n{\n    \"type\": \"https://example.com/probs/out-of-credit\",\n    \"title\": \"You do not have enough credit.\",\n    \"balance\": 30,\n    \"accounts\": [\"/account/12345\", \"/account/67890\"]\n}\n```\n\nthis code is required:\n\n```javascript\nconst ProblemDocument = require('http-problem-details').ProblemDocument;\nconst ProblemDocumentExtension = require('http-problem-details').ProblemDocumentExtension;\n\nconst extension = new ProblemDocumentExtension({\n  balance: 30,\n  accounts: ['/account/12345', '/account/67890']\n});\n\nconst doc = new ProblemDocument({\n  type: 'https://example.com/probs/out-of-credit',\n  title: 'You do not have enough credit.'\n}, extension);\n```\n\n## Using http-problem-details with express\nUsage of `http-problem-details` is described in `express-http-problem-details` ( [repository](https://github.com/PDMLab/express-http-problem-details) | [npm](https://www.npmjs.com/package/express-http-problem-details)).\n\n## Running the tests\n\n```\nnpm test\n```\n\n## TypeScript\n`http-problem-details` is implemented in TypeScript, hence providing typings out of the box.\n\n## Want to help?\n\nThis project is just getting off the ground and could use some help with cleaning things up and refactoring.\n\nIf you want to contribute - we'd love it! Just open an issue to work against so you get full credit for your fork. You can open the issue first so we can discuss and you can work your fork as we go along.\n\nIf you see a bug, please be so kind as to show how it's failing, and we'll do our best to get it fixed quickly.\n\nBefore sending a PR, please [create an issue](https://github.com/PDMLab/http-problem-details/issues/new) to introduce your idea and have a reference for your PR.\n\nWe're using [conventional commits](https://www.conventionalcommits.org), so please use it for your commits as well.\n\nAlso please add tests and make sure to run `npm run lint-ts`.\n\n## License\n\nMIT License\n\nCopyright (c) 2017 - 2019 PDMLab\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdmlab%2Fhttp-problem-details","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpdmlab%2Fhttp-problem-details","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdmlab%2Fhttp-problem-details/lists"}