1.0.1 • Published 8 years ago
res-handle v1.0.1
res-handle
Middleware for express. Adds handle method to res and can be easily used as a callback to make your code look cleaner. res.handle accept two argument: error and data. In the case of an error, it will return status 400. Otherwise it will return status 200 along with any provided data.
Install
$ npm install res-handle
Usage
Require:
const handle = require('res-handle');
Add Middleware:
app.use(handle);
Pass in callback:
Model.getData(res.handle)
Call in function:
getData(cb) => {
// do stuff
if (err) return cb(err);
cb(null, data);
});