express-http-errors-json

0.1.0 • Public • Published

express-http-errors-json

Easy access to HTTP errors for Express

Installation

$ npm install --save express-http-errors-json

Usage

This package exposes some commonly used abstracted HTTP errors to be returned along with short messages in JSON format. Mainly useful for JSON APIs.

import { BadRequest } from 'express-http-errors-json';
 
router.get('/', (req, res) => {
    BadRequest(res, 'The received request was invalid');
});

Exposed functions

Function name HTTP Code
BadRequest 400
Unauthenticated 401
Forbidden 403
NotFound 404
TooManyRequests 429
ServerError 500
BadGateway 502
ServiceUnavailable 503

About

License

Copyright © 2018, nukeop. Released under the Affero GPL 3.0 License.

Readme

Keywords

Package Sidebar

Install

npm i express-http-errors-json

Weekly Downloads

1

Version

0.1.0

License

AGPL-3.0

Unpacked Size

37.2 kB

Total Files

5

Last publish

Collaborators

  • nukeop