{"id":46858042,"url":"https://github.com/wintkhantlin/http-exceptions-express","last_synced_at":"2026-03-10T17:36:21.632Z","repository":{"id":328090431,"uuid":"1114191616","full_name":"wintkhantlin/http-exceptions-express","owner":"wintkhantlin","description":"Middleware Library for handling HTTP exceptions in Express","archived":false,"fork":false,"pushed_at":"2026-01-01T21:41:07.000Z","size":28,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-13T19:48:52.698Z","etag":null,"topics":["exceptions","express","express-middleware","http-exceptions","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/http-exceptions-express","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/wintkhantlin.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":null,"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":"2025-12-11T03:05:30.000Z","updated_at":"2025-12-13T12:25:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/wintkhantlin/http-exceptions-express","commit_stats":null,"previous_names":["happer64bit/http-exceptions-express","wintkhantlin/http-exceptions-express"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/wintkhantlin/http-exceptions-express","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wintkhantlin%2Fhttp-exceptions-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wintkhantlin%2Fhttp-exceptions-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wintkhantlin%2Fhttp-exceptions-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wintkhantlin%2Fhttp-exceptions-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wintkhantlin","download_url":"https://codeload.github.com/wintkhantlin/http-exceptions-express/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wintkhantlin%2Fhttp-exceptions-express/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30344675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:55:29.454Z","status":"ssl_error","status_checked_at":"2026-03-10T15:54:58.440Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["exceptions","express","express-middleware","http-exceptions","typescript"],"created_at":"2026-03-10T17:36:19.674Z","updated_at":"2026-03-10T17:36:21.591Z","avatar_url":"https://github.com/wintkhantlin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express HTTP Exception Middleware\n\nA simple, TypeScript-friendly middleware for handling HTTP exceptions in Express apps. Provides structured JSON error responses with optional timestamps.\n\n---\n\n## Installation\n\n```bash\nnpm install http-exceptions-express\n````\n\n---\n\n## Usage\n\n### Basic Setup\n\n```ts\nimport express from \"express\";\nimport { httpExceptionMiddleware, NotFoundException } from 'http-exceptions-express';\n\nconst app = express();\n\napp.get(\"/hello\", (req, res) =\u003e res.json({ msg: \"Hello\" }));\n\napp.get(\"/not-found-example\", () =\u003e { throw new NotFoundException(); });\n\n// Register error middleware last\napp.use(httpExceptionMiddleware({ useTimestamp: true }));\n\napp.listen(8000);\n```\n\n### Example Error Response\n\nRequesting `/not-found-example` will return:\n\n```json\n{\n  \"message\": \"Not Found\",\n  \"timestamp\": \"2025-12-11T12:34:56.789Z\"\n}\n```\n\n---\n\n## API\n\n### `httpExceptionMiddleware(options?: { useTimestamp?: boolean })`\n\n* `useTimestamp` (boolean, default: `false`): Include a timestamp in the error response.\n\nReturns an Express error-handling middleware.\n\n### `NotFoundException`\n\nA prebuilt `HttpException` with `status = 404` and `message = \"Not Found\"`.\n\n---\n\n## Creating Custom Exceptions\n\n```ts\nimport { HttpException } from '@happer64bit/http-exceptions-express';\n\nclass UnauthorizedException extends HttpException {\n    constructor(message = \"Unauthorized\") {\n        super(401, message);\n    }\n}\n\nthrow new UnauthorizedException();\n```\n\n---\n\n## Notes\n\n* **Middleware order matters**: In Express, error-handling middleware must be registered **after all routes** to catch errors properly.\n* For synchronous routes, this works out-of-the-box.\n* For async routes, consider wrapping with a helper like `asyncHandler` to forward errors.\n\n---\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwintkhantlin%2Fhttp-exceptions-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwintkhantlin%2Fhttp-exceptions-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwintkhantlin%2Fhttp-exceptions-express/lists"}