š± Literal HTTP codes & statuses.
npm install ltrl-httpš± Literal HTTP codes & statuses.
1. Install the module
``bash`
pnpm add ltrl-http
2. Start using HTTP codes
`bash
import { status } from "ltrl-http";
status.OK; // 200
status.FORBIDDEN; // 401
status.UNAUTHORIZED; // 403
// etc
`
3. HTTP status codes are ready to go!
| Function | Description |
| ----------------------- | ---------------------------------------------------------- |
| isHTTPCode(code) | Check if a given value is a valid HTTP code. |useHTTPCode(code)
| | Resolve a given HTTP code to an HTTP status configuration. |useHTTPCodeConfig()
| | Access the ltrl HTTP code definition. |isHTTPStatus(status)
| | Check if a given value is a valid HTTP status. |useHTTPStatus(status)
| | Exchange an HTTP status for an HTTP code. |useHTTPStatusConfig()
| | Access the ltrl HTTP status definition. |
| Type | Description |
| -------------------------------------- | -------------------------------------------------------------------------- |
| HTTPCode | A number-literal union type of all available HTTP status codes. |HTTPStatus
| | A string-literal union type of all available HTTP statuses. |HTTPStatusCode
| ` | Resolve the expected literal HTTP code type of a given HTTP status string; |
MIT License © 2024-PRESENT Alexander Thorwaldson