A TypeScript HTTP Status Code Library based on IETF RFC9110 Section 15
Install package:
# npm
npm install @fimion/ts-http-status-codes
# pnpm
pnpm install @fimion/ts-http-status-codes
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
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";
- Clone this repository
- Enable Corepack using
corepack enable
- Install dependencies using
pnpm install
- Run interactive tests using
pnpm dev
Made with ❤️
Published under MIT License.