Skip to content

Commit a9ec9fa

Browse files
added a 404 error
1 parent 340b71e commit a9ec9fa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ app.use('/reported', casesRoute);
1515
app.use('/recovered', recoveredRoute);
1616
app.use('/deaths', deathsRoute);
1717
app.use('/', indexRoute);
18+
19+
app.use(function(req, res, next) {
20+
if (res.status(404)) {
21+
// respond with error
22+
res.json({ error: 'Not found' });
23+
}
24+
25+
26+
});
27+
1828
app.listen(app.get('port'), () => {
1929
console.log(`Server started on port ${app.get('port')}`);
2030
});

0 commit comments

Comments
 (0)