🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

error-status-helper

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

error-status-helper

Extends node.js response middleware with status codes helper methods.

Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

error-status-helper

Extends express response middleware with status codes helper methods.

Installation

$ npm install error-status-helper

Example

javascript

  • simple example
var express = require('express');
var errorStatus = require('error-status-helper');

var app = express();
app.use(errorStatus);

  • custom example
var express = require('express');
var _statusCodes = require('./statusCodes.js');
var errorStatus = require('error-status-hepler').use(_statusCodes);

var app = express();
app.use(errorStatus);

statusCode.js format

the default code is using the http code, you can define you own business code in statusCode property.

module.exports = {
   Bad_Request: {
        code: 400,
        statusCode:401001,
        message: {
            en: "Bad Request"
        }
    },
}

You using in you code only available in express

app.use("/badRequest", function (req, res, next) {
    res.Bad_Request();
})

app.use("/forbidden", function (req, res, next) {
    var errMsg = {statusCode: -1, message: 'you can not use this interface'};
    res.Forbidden(errMsg);
})

FAQs

Package last updated on 27 Jul 2016

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