Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 28, 2024 via pnpm

http-errors 0.0.1

A node module that returns a hash of Error classes representing HTTP errors indexed by error code.
Package summary
Share
1
issue
1
critical severity
license
1
1
license
1
N/A
Package created
18 Nov 2012
Version published
18 Nov 2012
Maintainers
3
Total deps
1
Direct deps
0
License
UNKNOWN

Issues

1

1 critical severity issue

critical
Recommendation: Check the package code and files for license information
via: http-errors@0.0.1
Collapse
Expand

Licenses

N/A

N/A
1 Packages, Including:
http-errors@0.0.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of http-errors 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does http-errors do?

The http-errors package is a valuable tool for creating HTTP errors with ease in applications that use Express, Koa, Connect, and similar frameworks. Conveniently accessible through the npm registry, this package works to streamline the creation of comprehensive error objects for HTTP transactions.

How do you use http-errors?

To utilize the http-errors package in your Node.js applications, first install the package using the command npm install http-errors. Once installed, you can require it in your application file. Here's an simple usage example:

var createError = require('http-errors');
var express = require('express');
var app = express();

app.use(function (req, res, next) {
  if (!req.user) return next(createError(401, 'Please login to view this page.'));
  next();
});

In the example above, if the user object is not available in the request, the middleware creates an HTTP 401 error using http-errors and passes it to the next middleware or the error handling middleware.

Moreover, with the http-errors package, you can either use status codes directly - as in createError(404, 'This video does not exist!') - or the constructor names, using camel case (i.e., new createError.NotFound()).

Where are the http-errors docs?

Comprehensive documentation for http-errors is provided directly in the README file in its GitHub repository at https://github.com/jshttp/http-errors. The document stipulates API details, usage examples, and an exhaustive list of status codes with their corresponding error constructor names in camel case. Whether you're looking to implement particular status codes or discern specific error properties, this documentation is a must-consult resource.