mirror of
https://github.com/spacedeck/spacedeck-open.git
synced 2025-12-17 02:17:30 +01:00
initial commit.
This commit is contained in:
16
middlewares/error_helpers.js
Normal file
16
middlewares/error_helpers.js
Normal file
@@ -0,0 +1,16 @@
|
||||
'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();
|
||||
}
|
||||
Reference in New Issue
Block a user