mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-14 13:49:40 -06:00
21 lines
405 B
JavaScript
21 lines
405 B
JavaScript
const responseHandler = (req, res, next) => {
|
|
res.success = ({ status = 200, msg = "OK", data = null }) => {
|
|
return res.status(status).json({
|
|
success: true,
|
|
msg: msg,
|
|
data: data,
|
|
});
|
|
};
|
|
|
|
res.error = ({ status = 500, msg = "Internal server error", data = null }) => {
|
|
return res.status(status).json({
|
|
success: false,
|
|
msg,
|
|
data,
|
|
});
|
|
};
|
|
next();
|
|
};
|
|
|
|
export { responseHandler };
|