14 lines
358 B
JavaScript
14 lines
358 B
JavaScript
// @ts-check
|
|
function notFound(_req, res) {
|
|
res.status(404).json({ message: 'Not Found' });
|
|
}
|
|
|
|
function errorHandler(err, _req, res, _next) {
|
|
const status = err.status || 500;
|
|
const message = err.message || 'Server Error';
|
|
if (status >= 500) console.error(err);
|
|
res.status(status).json({ message });
|
|
}
|
|
|
|
module.exports = { notFound, errorHandler };
|