From 6e32d0678a89f507c7d8a6dedac1593eee853204 Mon Sep 17 00:00:00 2001 From: Gilbert Date: Wed, 19 Jun 2024 22:31:07 -0500 Subject: [PATCH] Add generic error handling --- packages/backend/src/routes/staging.ts | 2 +- packages/backend/src/server.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/routes/staging.ts b/packages/backend/src/routes/staging.ts index 8adfcd76..979833e6 100644 --- a/packages/backend/src/routes/staging.ts +++ b/packages/backend/src/routes/staging.ts @@ -3,7 +3,7 @@ import { Router } from 'express'; const router = Router(); router.get('/version', async (req, res) => { - return res.send({ version: '0.0.4' }); + return res.send({ version: '0.0.5' }); }); export default router; diff --git a/packages/backend/src/server.ts b/packages/backend/src/server.ts index b1717ca3..26c133be 100644 --- a/packages/backend/src/server.ts +++ b/packages/backend/src/server.ts @@ -112,6 +112,11 @@ export const createAndStartServer = async ( app.use('/api/github', githubRouter); app.use('/staging', stagingRouter); + app.use((err: any, req: any, res: any, next: any) => { + console.error(err); + res.status(500).json({ error: 'Internal Server Error' }); + }); + httpServer.listen(port, host, () => { log(`Server is listening on ${host}:${port}${server.graphqlPath}`); });