{"id":50720519,"url":"https://github.com/mstuart/problem-response","last_synced_at":"2026-06-09T23:30:49.528Z","repository":{"id":362422700,"uuid":"1158825705","full_name":"mstuart/problem-response","owner":"mstuart","description":"RFC 9457 Problem Details for HTTP APIs — framework-agnostic, TypeScript-first error responses","archived":false,"fork":false,"pushed_at":"2026-06-04T05:52:37.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-04T07:13:30.382Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mstuart.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-16T00:44:24.000Z","updated_at":"2026-06-04T05:53:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mstuart/problem-response","commit_stats":null,"previous_names":["mstuart/problem-response"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/mstuart/problem-response","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstuart%2Fproblem-response","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstuart%2Fproblem-response/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstuart%2Fproblem-response/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstuart%2Fproblem-response/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mstuart","download_url":"https://codeload.github.com/mstuart/problem-response/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstuart%2Fproblem-response/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34130641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-06-09T23:30:47.572Z","updated_at":"2026-06-09T23:30:49.518Z","avatar_url":"https://github.com/mstuart.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# problem-response\n\n\u003e RFC 9457 Problem Details for HTTP APIs — framework-agnostic, TypeScript-first error responses\n\n## Install\n\n```sh\nnpm install problem-response\n```\n\n## Usage\n\n```js\nimport {ProblemDetail, toResponse, notFound, badRequest} from 'problem-response';\n\n// Using factory functions\nconst problem = notFound('The requested user was not found.');\nconsole.log(problem.toJSON());\n// =\u003e {type: 'about:blank', title: 'Not Found', status: 404, detail: 'The requested user was not found.'}\n\n// Using the constructor directly\nconst detailed = new ProblemDetail({\n\ttype: 'https://api.example.com/problems/out-of-credit',\n\ttitle: 'You do not have enough credit.',\n\tstatus: 403,\n\tdetail: 'Your current balance is 30, but that costs 50.',\n\tinstance: '/account/12345/msgs/abc',\n\tbalance: 30,\n\taccounts: ['/account/12345', '/account/67890'],\n});\n\n// Convert to HTTP response\nconst response = toResponse(detailed);\n// =\u003e {status: 403, headers: {'content-type': 'application/problem+json'}, body: '...'}\n```\n\n## API\n\n### `new ProblemDetail(options)`\n\nCreates a new `ProblemDetail` instance that extends `Error`.\n\n#### options\n\nType: `object`\n\n##### type\n\nType: `string`\\\nDefault: `'about:blank'`\n\nA URI reference that identifies the problem type.\n\n##### title\n\nType: `string`\n\nA short, human-readable summary of the problem type. Defaults to the standard title for the given status code.\n\n##### status\n\nType: `number` *(required)*\n\nThe HTTP status code for this problem.\n\n##### detail\n\nType: `string`\n\nA human-readable explanation specific to this occurrence of the problem.\n\n##### instance\n\nType: `string`\n\nA URI reference that identifies the specific occurrence of the problem.\n\n##### Extension members\n\nAny additional properties are treated as extension members per RFC 9457.\n\n### `.toJSON()`\n\nReturns an RFC 9457 compliant plain object.\n\n### `toResponse(problem)`\n\nReturns an HTTP response object with `status`, `headers`, and `body`.\n\n### `isProblemDetail(value)`\n\nType guard that returns `true` if the value is a `ProblemDetail` instance.\n\n### Factory functions\n\n- `badRequest(detail?, extensions?)` — status 400\n- `unauthorized(detail?, extensions?)` — status 401\n- `forbidden(detail?, extensions?)` — status 403\n- `notFound(detail?, extensions?)` — status 404\n- `conflict(detail?, extensions?)` — status 409\n- `unprocessableEntity(detail?, extensions?)` — status 422\n- `internalServerError(detail?, extensions?)` — status 500\n\n## Related\n\n- [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) — Problem Details for HTTP APIs\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstuart%2Fproblem-response","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmstuart%2Fproblem-response","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstuart%2Fproblem-response/lists"}