Skip to content

Instantly share code, notes, and snippets.

@birendra-b
Created June 29, 2020 16:40
Show Gist options
  • Save birendra-b/8494767e185f62616fbbe0154c2421af to your computer and use it in GitHub Desktop.
Save birendra-b/8494767e185f62616fbbe0154c2421af to your computer and use it in GitHub Desktop.
Server.ts with API bad request error handler
// Print API errors
// eslint-disable-next-line @typescript-eslint/no-unused-vars
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
logger.error(err.message, err);
return res.status(BAD_REQUEST).json({
error: err.message,
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment