Use AJV, refactor a lot
This commit is contained in:
11
api/app.js
11
api/app.js
@@ -76,10 +76,13 @@ app.get(`/*`, (req, res) => {
|
||||
/**
|
||||
* Error Handler
|
||||
*/
|
||||
app.use(function (err, req, res) {
|
||||
console.error(err);
|
||||
res.status(500).json({
|
||||
error: `Internal Serverless Error - "${err.message}"`,
|
||||
app.use(function (err, req, res, next) {
|
||||
if (res.headersSent) {
|
||||
return next(err);
|
||||
}
|
||||
res.status(err.code || 500);
|
||||
res.json({
|
||||
error: err.message || `Internal Server Error - "${err.message}"`,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user