
feat: Ability to get the db variable from everywhere with getDatabase function feat: Hello world when getting root url fix: Now mods model is able to communicate with db fix: fixed a syntax error in routes/mods.js file which caused sending two responses to the client
19 lines
426 B
JavaScript
19 lines
426 B
JavaScript
const AppError = require("../utils/AppError");
|
|
|
|
const handleError = (err, req, res, next) => {
|
|
// Send
|
|
if (err instanceof AppError) {
|
|
return res.status(err.statusCode).json({
|
|
message: err.message,
|
|
status: err.status
|
|
});
|
|
}
|
|
|
|
// Default error
|
|
res.status(500).json({
|
|
message: 'Internal server error',
|
|
status: 500
|
|
});
|
|
}
|
|
|
|
module.exports = handleError; |