Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joonhocho/tshttpcode
HTTP Status Code enum in TypeScript optimized for tree shaking
https://github.com/joonhocho/tshttpcode
Last synced: about 1 month ago
JSON representation
HTTP Status Code enum in TypeScript optimized for tree shaking
- Host: GitHub
- URL: https://github.com/joonhocho/tshttpcode
- Owner: joonhocho
- License: mit
- Created: 2019-06-26T10:12:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T03:58:24.000Z (almost 2 years ago)
- Last Synced: 2024-11-11T11:12:06.493Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 942 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tshttpcode
HTTP Status Code enum in TypeScript optimized for tree shaking[![npm version](https://badge.fury.io/js/tshttpcode.svg)](https://badge.fury.io/js/tshttpcode)
[![npm](https://img.shields.io/npm/dw/tshttpcode.svg)](https://www.npmjs.com/package/tshttpcode)
![npm type definitions](https://img.shields.io/npm/types/tshttpcode.svg)
[![Build Status](https://travis-ci.org/joonhocho/tshttpcode.svg?branch=master)](https://travis-ci.org/joonhocho/tshttpcode)
[![Dependency Status](https://david-dm.org/joonhocho/tshttpcode.svg)](https://david-dm.org/joonhocho/tshttpcode)
[![GitHub](https://img.shields.io/github/license/joonhocho/tshttpcode.svg)](https://github.com/joonhocho/tshttpcode/blob/master/LICENSE)## Get Started
```
npm install -D tshttpcode
```
or
```
yarn add -D tshttpcode
```## How to Use
```typescript
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](https://github.com/joonhocho/tshttpcode/blob/master/LICENSE)