mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-10 15:48:27 -05:00
Add error handling middleware
This commit is contained in:
parent
a00a3efbf6
commit
afbebc977e
@ -55,6 +55,12 @@ app.use(express.static(__dirname + '/public'));
|
|||||||
require('./app/routes/routes.js')(app);
|
require('./app/routes/routes.js')(app);
|
||||||
require('./config/passport.js');
|
require('./config/passport.js');
|
||||||
|
|
||||||
|
// Error handler
|
||||||
|
app.use((err, req, res, next) => {
|
||||||
|
console.error(err.stack);
|
||||||
|
res.status(500).json({'message': 'Internal server error.'});
|
||||||
|
});
|
||||||
|
|
||||||
// Start app
|
// Start app
|
||||||
const port = process.env.PORT || 8080;
|
const port = process.env.PORT || 8080;
|
||||||
const server = app.listen(port);
|
const server = app.listen(port);
|
||||||
@ -63,7 +69,7 @@ console.log('Listening on port ' + port + '...\n');
|
|||||||
// Handle sigint
|
// Handle sigint
|
||||||
process.on('SIGINT', () => {
|
process.on('SIGINT', () => {
|
||||||
console.log('Shutting down...');
|
console.log('Shutting down...');
|
||||||
process.exitCode = 0;
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Expose app
|
// Expose app
|
||||||
|
Loading…
Reference in New Issue
Block a user