chore(server): Move api-server in to it's own DIR
This commit is contained in:
committed by
mrugesh mohapatra
parent
9fba6bce4c
commit
46a217d0a5
22
api-server/server/boot/z-not-found.js
Normal file
22
api-server/server/boot/z-not-found.js
Normal file
@ -0,0 +1,22 @@
|
||||
import accepts from 'accepts';
|
||||
|
||||
export default function fourOhFour(app) {
|
||||
app.all('*', function(req, res) {
|
||||
const accept = accepts(req);
|
||||
const type = accept.type('html', 'json', 'text');
|
||||
const { path } = req;
|
||||
|
||||
|
||||
if (type === 'html') {
|
||||
req.flash('danger', `We couldn't find path ${ path }`);
|
||||
return res.render('404', { title: '404'});
|
||||
}
|
||||
|
||||
if (type === 'json') {
|
||||
return res.status('404').json({ error: 'path not found' });
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
return res.send('404 path not found');
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user