New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http-error-prototype

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-error-prototype

A simple module to deal coherently with HTTP errors in Express

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

HTTP error prototype

A simple module to deal coherently with HTTP errors in Express. Has conveniency methods for the most commons HTTP error codes. See http-error-express for the companion error handling middleware.

Usage

var express = require('express');
var HttpError = require('http-error-prototype');

var router = express.Router();

// Shorthand method
router.get('/shorthand', function(req, res, next) {
	return next(HttpError.notFound("Some not found message", { someProp: "someVal" }));
});

// Constructor
router.get('/constructor', function(req, res, next) {
	return next(new HttpError(404, "Some not found message", { someProp: "someVal" }));
});

module.exports = router;

API

  • new HttpError(status, message, data).
  • HttpError.badRequest(status, message, data).
  • HttpError.unauthorized(status, message, data).
  • HttpError.forbidden(status, message, data).
  • HttpError.notFound(status, message, data).
  • HttpError.methodNotAllowed(status, message, data).
  • HttpError.notAcceptable(status, message, data).
  • HttpError.requestTimeout(status, message, data).
  • HttpError.conflict(status, message, data).

Both message and data are optional.

FAQs

Package last updated on 06 Aug 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc