ltrl-http
v0.0.20
Published
🍱 Literal HTTP codes & statuses.
Readme
ltrl-http
🍱 Literal HTTP codes & statuses.
Getting Started
- Install the module
pnpm add ltrl-http- Start using HTTP codes
import { status } from "ltrl-http";
status.OK; // 200
status.FORBIDDEN; // 401
status.UNAUTHORIZED; // 403
// etc- HTTP status codes are ready to go!
Utils
| 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. |
Types
| 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<S extends HTTPStatus> | Resolve the expected literal HTTP code type of a given HTTP status string; |
License
MIT License © 2024-PRESENT Alexander Thorwaldson
