@fimion/ts-http-status-codes
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.2 • Public • Published

@fimion/ts-http-status-codes

npm version npm downloads Github Actions Codecov

A TypeScript HTTP Status Code Library based on IETF RFC9110 Section 15

Usage

Install package:

# npm
npm install @fimion/ts-http-status-codes

# pnpm
pnpm install @fimion/ts-http-status-codes

JavaScript Usage

import {
  HTTP_CODES, // Has names for all codes in RFC 9110
  HTTP_CODES_4XX, // Only has names for codes in the 4xx block
} from "@fimion/ts-http-status-codes";

console.log(HTTP_CODES.OK) // 200
console.log(HTTP_CODES.NOT_FOUND) // 404

console.log(HTTP_CODES_4XX.NOT_FOUND) // 404
console.log(HTTP_CODES_4XX.OK) // undefined

TypeScript Usage

import type {
  TYPE_HTTP_CODE, // Matches all codes specified by RFC 9110
  LOOSE_TYPE_HTTP_CODE, // Matches integers 100 to 599
  TYPE_HTTP_CODE_2XX, // Strict, only codes in the 2xx range specified by RFC 9110
  LOOSE_TYPE_HTTP_CODE_2XX, // Matches integers 200 to 299
} from "@fimion/ts-http-status-codes";

💻 Development

  • Clone this repository
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with ❤️

Published under MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i @fimion/ts-http-status-codes

Weekly Downloads

130

Version

1.0.0-beta.2

License

MIT

Unpacked Size

170 kB

Total Files

6

Last publish

Collaborators

  • fimion