registration-js-vanilla/src/middlewares/responses.js
2023-09-11 14:13:41 +03:00

22 lines
404 B
JavaScript

function notFound(res) {
res.statusCode = 404;
res.end('Not Found');
}
function methodNotAllowed(res) {
res.statusCode = 405;
res.end('Method Not Allowed');
}
function sendResponse(res, statusCode, data) {
res.setHeader("Content-Type", "application/json");
res.statusCode = statusCode;
res.end(JSON.stringify(data));
}
module.exports = {
notFound,
methodNotAllowed,
sendResponse
}