Add generic error handling

This commit is contained in:
Gilbert 2024-06-19 22:31:07 -05:00
parent 198478f5fa
commit 6e32d0678a
2 changed files with 6 additions and 1 deletions

View File

@ -3,7 +3,7 @@ import { Router } from 'express';
const router = Router(); const router = Router();
router.get('/version', async (req, res) => { router.get('/version', async (req, res) => {
return res.send({ version: '0.0.4' }); return res.send({ version: '0.0.5' });
}); });
export default router; export default router;

View File

@ -112,6 +112,11 @@ export const createAndStartServer = async (
app.use('/api/github', githubRouter); app.use('/api/github', githubRouter);
app.use('/staging', stagingRouter); 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, () => { httpServer.listen(port, host, () => {
log(`Server is listening on ${host}:${port}${server.graphqlPath}`); log(`Server is listening on ${host}:${port}${server.graphqlPath}`);
}); });