npm.io
2.0.0 • Published 5 years ago

@cley_faye/http-codes-consts

Licence
MIT
Version
2.0.0
Deps
0
Size
16 kB
Vulns
0
Weekly
0

List of HTTP codes as constants

This is a simple list, to avoid magic numbers in the code as well as add a bit of safety when using TypeScript.

The list of codes is taken from the IANA.

Installation

This is on npmjs:

npm install @cley_faye/http-codes-consts

Usage

Constants are available as the default export:

import HttpCodes from "@cley_faye/http-codes-consts";
console.log(HttpCodes.NotFound); // Output 404
console.log(HttpCodes.NOT_FOUND); // Output 404

Names are available in both camel-case and uppercase separated with an underline.

Caveats

Unfortunately, as this is generated from a "serious" CSV source, the "I'm a Teapot" error is not available.