[QOTD-18] Implement global error-handling middleware #5

Open
ai-implementer wants to merge 1 commits from ssmp/qotd-18-r6 into main
Member

Summary

Adds a global Express error-handling middleware so unhandled errors return a safe, generic HTTP 500 response instead of leaking internals or stack traces to clients.

Changes Made

  • Added src/middleware/error.ts with a four-argument Express error handler that logs the error server-side via console.error and responds with HTTP 500 and { error: 'Internal server error' }
  • Added src/server.ts, a minimal Express app entry point that mounts express.json() and registers the error handler last (required since server.ts did not yet exist in this repo)

Notes

server.ts currently only wires up JSON body parsing and the error handler; routes, the quote store, and validation are tracked separately under QOTD-13/QOTD-7/QOTD-10 and will be merged into this entry point in follow-up work. Verified with tsc --noEmit (clean) and npm test (1/1 passing).


Task: QOTD-18
Commit: [QOTD-18] Implement global error-handling middleware

## Summary Adds a global Express error-handling middleware so unhandled errors return a safe, generic HTTP 500 response instead of leaking internals or stack traces to clients. ## Changes Made - Added `src/middleware/error.ts` with a four-argument Express error handler that logs the error server-side via `console.error` and responds with HTTP 500 and `{ error: 'Internal server error' }` - Added `src/server.ts`, a minimal Express app entry point that mounts `express.json()` and registers the error handler last (required since `server.ts` did not yet exist in this repo) ## Notes `server.ts` currently only wires up JSON body parsing and the error handler; routes, the quote store, and validation are tracked separately under QOTD-13/QOTD-7/QOTD-10 and will be merged into this entry point in follow-up work. Verified with `tsc --noEmit` (clean) and `npm test` (1/1 passing). --- Task: QOTD-18 Commit: [QOTD-18] Implement global error-handling middleware
ai-implementer added 1 commit 2026-09-14 08:01:04 +00:00
Add src/middleware/error.ts with a four-argument Express error handler
that logs errors server-side via console.error and responds with HTTP
500 and a generic { error: 'Internal server error' } body, never
leaking stack traces to the client. Register it last in a new
src/server.ts entry point.
ai-reviewer reviewed 2026-09-14 08:01:12 +00:00
ai-reviewer left a comment
Member

AI review (ai-reviewer) — no issues found. Reviewed against the project rules; nothing rule-citable to flag.

✅ **AI review** (ai-reviewer) — no issues found. Reviewed against the project rules; nothing rule-citable to flag.
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin ssmp/qotd-18-r6:ssmp/qotd-18-r6
git checkout ssmp/qotd-18-r6
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: scopic-software/quote-of-the-day-api#5
No description provided.