powr-sdk-api
Version:
Shared API core library for PowrStack projects
18 lines (16 loc) • 482 B
JavaScript
;
const logger = require("../logger");
// Handler for 404 Not Found errors
const notFoundHandler = (req, res) => {
// Log the 404 error
logger.warn(`Route not found: ${req.method} ${req.path}`, {
requestId: req.requestId,
ip: req.ip,
userAgent: req.headers['user-agent']
});
// Return a consistent JSON response
return res.error('The requested resource was not found', 404, `${req.method} ${req.path}`);
};
module.exports = {
notFoundHandler
};