forked from cerc-io/snowballtools-base
Add generic error handling
This commit is contained in:
parent
198478f5fa
commit
6e32d0678a
@ -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;
|
||||||
|
@ -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}`);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user