Skip to content

joonhocho/tshttpcode

Repository files navigation

tshttpcode

HTTP Status Code enum in TypeScript optimized for tree shaking

npm version npm npm type definitions Build Status Dependency Status GitHub

Get Started

npm install -D tshttpcode

or

yarn add -D tshttpcode

How to Use

import { getHttpStatus, HttpStatus, NOT_FOUND } from 'tshttpcode';

NOT_FOUND // { code: 404, name: 'not_found', text: 'Not Found' }

HttpStatus[404] === NOT_FOUND

HttpStatus.not_found === NOT_FOUND

HttpStatus.BAD_STATUS_NAME === undefined // typescript error

getHttpStatus(404) === NOT_FOUND

getHttpStatus('404') === NOT_FOUND

getHttpStatus(9000) === undefined // typescript error

getHttpStatus('NOT_FOUND') === NOT_FOUND

getHttpStatus(' nOt  fOuNd ') === NOT_FOUND

License

MIT License

About

HTTP Status Code enum in TypeScript optimized for tree shaking

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published