res-handle

1.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i res-handle

Weekly Downloads

0

Version

1.0.1

License

ISC

Last publish

Collaborators

  • donbobvanbirt