1.0.1 • Published 8 years ago

res-handle v1.0.1

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

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);
});
1.0.1

8 years ago

1.0.0

8 years ago