tshttpcode
v0.0.11
Published
HTTP Status Code enum in TypeScript
Downloads
6
Maintainers
Readme
tshttpcode
HTTP Status Code enum in TypeScript optimized for tree shaking
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