New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

inblox-node-http

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inblox-node-http

inblox node http

latest
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

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

// you want statusCode in response, that is for badRequest,serverError,postSuccessfully,getSuccessfully methods 
app.use('/', nodeHttp( { sendStatusCodeinRespose: true }), 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, unauthenticated request
res.unAuthorized();

// HTTP Code:403, unauthorized request
res.forbidden();

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

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

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

// HTTP Code:200, for get request
res.getRequest({ name: 'john Dow' });

// HTTP Code:201, for post request
res.postRequest();

// HTTP Code:204, for update,patch request
res.updated();

// HTTP Code:204, for delete request
res.deleted();

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

Keywords

node-http

FAQs

Package last updated on 18 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts