Socket
Socket
Sign inDemoInstall

@types/http-errors

Package Overview
Dependencies
0
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/http-errors

TypeScript definitions for http-errors


Version published
Weekly downloads
14M
decreased by-1.52%
Maintainers
1
Install size
6.80 kB
Created
Weekly downloads
 

Package description

What is @types/http-errors?

The @types/http-errors package provides TypeScript type definitions for the http-errors package, which is used to create HTTP error objects. These type definitions allow TypeScript developers to use the http-errors package in a type-safe manner, ensuring that they are using the correct types for the various functions and constructors provided by http-errors.

What are @types/http-errors's main functionalities?

Creating HTTP Error Objects

This feature allows developers to create HTTP error objects with a status code and message. The example demonstrates creating a 404 Not Found error.

import createError from 'http-errors';

const NotFoundError = createError(404, 'This page does not exist.');
console.log(NotFoundError.status); // 404
console.log(NotFoundError.message); // 'This page does not exist.'

Type Checking for HTTP Error Objects

This feature provides type definitions for handling HTTP errors in a type-safe way. The example shows a function that accepts an HttpError object, demonstrating the use of TypeScript for type checking.

import createError, { HttpError } from 'http-errors';

function handleError(error: HttpError) {
  console.log(error.status);
  console.log(error.message);
}

const myError = createError(500, 'Internal Server Error');
handleError(myError);

Other packages similar to @types/http-errors

Readme

Source

Installation

npm install --save @types/http-errors

Summary

This package contains type definitions for http-errors (https://github.com/jshttp/http-errors).

Details

Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/http-errors

Additional Details

  • Last updated: Wed, 28 Dec 2016 00:18:24 GMT
  • Library Dependencies: none
  • Module Dependencies: none
  • Global values: none

Credits

These definitions were written by Tanguy Krotoff https://github.com/tkrotoff.

FAQs

Last updated on 28 Dec 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc