availity-ekko
Version:
Mock server simulating Availity API rest services
31 lines (22 loc) • 716 B
JavaScript
module.exports = function notfound() {
return function(req, res) {
res.status(404);
var message = 'Not Found';
if (req.accepts('html')) {
res.type('html').status(404).end('<!DOCTYPE html> <html> <head> <title>Dummy Mock Server Response</title> </head> <body> <h1>Not Found<h1> </body> </html>');
return;
}
// respond with json
if (req.accepts('json')) {
res.type('json').send({ error: message });
return;
}
// respond with json
if (req.accepts('xml')) {
res.type('xml').send('<error><message>' + message + '</message></error>');
return;
}
// default to plain-text. send()
res.type('txt').send({ error: message });
};
};