inblox-node-http
inblox node http
Last updated 2 months ago by manoj.kaushik .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install inblox-node-http 
SYNC missed versions from official npm registry.

inblox-node-http

Custom http-error module which will used to customize rest api response as per inblox network standards

Installation

This is a Node.js module available through the npm registry. It can be installed using the npm or yarn command line tools.

npm install inblox-node-http --save

Tests

npm install
npm test

Usage

To use this middleware need to add the following code in your entry file generally which is either index.js, app.js or server.js

const nodeHttp = require('inblox-node-http');
app.use('/', nodeHttp(), router);

Method

// HTTP Code:200
res.getSuccessfully({ data: [{userId:1}], message: 'successfully saved'});

// HTTP Code:201
res.postSuccessfully({ data: [{userId:1}], message: 'successfully saved'});

// HTTP Code:400
res.badRequest('filed-validation', [{name:'userId',message:'invalid userId']);

// HTTP Code:401
res.unAuthorized();

// HTTP Code:403
res.forbidden('filed-validation', [{name:'userId',message:'invalid userId']);

// HTTP Code:404
res.notFound();

// HTTP Code:412
res.concurrencyError();

// HTTP Code:500
res.serverError(error);

Reference

To get better vision about the response structure for 4.x.x series and 5.x.x series check the following link. HTTP response structure

Dependencies

None

Dev Dependencies

  • chai: BDD/TDD assertion library for node.js and the browser. Test framework agnostic.
  • mocha: simple, flexible, fun test framework
  • sinon: JavaScript test spies, stubs and mocks.

License

MIT

Current Tags

  • 0.4.0                                ...           latest (2 months ago)

3 Versions

  • 0.4.0                                ...           2 months ago
  • 0.3.0                                ...           2 months ago
  • 0.1.0                                ...           5 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |