UNPKG

@zishone/jasenda

Version:

A middleware to add jsend helper functions to the response object

32 lines 923 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.jsend = void 0; const jsend = () => { return (_req, res, next) => { res.jsend = { success: (data, statusCode = 200) => { res.status(statusCode).send({ status: 'success', data, }); }, fail: (data, statusCode = 400) => { res.status(statusCode).send({ status: 'fail', data, }); }, error: (message, statusCode = 500, code, data) => { res.status(statusCode).send({ status: 'error', message, code, data, }); }, }; next(); }; }; exports.jsend = jsend; //# sourceMappingURL=jsend.js.map