tshttpcode
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

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

/tshttpcode/

    Package Sidebar

    Install

    npm i tshttpcode

    Weekly Downloads

    13

    Version

    0.0.11

    License

    MIT

    Unpacked Size

    90.5 kB

    Total Files

    32

    Last publish

    Collaborators

    • joonhocho