spacedeck-open/middlewares/error_helpers.js

17 lines
287 B
JavaScript
Raw Permalink Normal View History

2017-04-07 01:29:05 +02:00
'use strict';
module.exports = (req, res, next) => {
res.bad_request = (msg) => {
if (req.accepts('text/html')) {
res.status(400).render('error', {
message: msg
});
} else {
res.status(400).json({
"error": msg
});
}
}
next();
}