The error handling in server/index.js is currently duplicated across routes.
- Create a
middleware/errorMiddleware.js file.
- Standardize the error response format (e.g.,
{ success: false, message: "...", code: 500 }).
- Refactor existing routes to use
next(error) to pass errors to the centralized handler.
The error handling in
server/index.jsis currently duplicated across routes.middleware/errorMiddleware.jsfile.{ success: false, message: "...", code: 500 }).next(error)to pass errors to the centralized handler.