UNPKG

merest

Version:

Express based REST-full API for Mongoose models

24 lines (19 loc) 549 B
module.exports = exports = registerApi; /** * registerApi - the factory for middleware that registers api in response object * * @param {ModelAPIRouter|ModelAPIExpress} apiObject the ModelAPIRouter or ModelAPIRouter * @return {Function} description */ function registerApi(isApp, apiObject) { if (isApp) { return function (req, res, next) { res.__api = apiObject; return next(); }; }; return function (req, res, next) { res.__modelAPI = apiObject; return next(); }; }