@vicstack/http
v0.2.0
Published
Named HTTP status codes as a plain object, with no runtime dependencies.
Readme
@vicstack/http
Named HTTP status codes, as a plain object — no runtime dependencies.
import HTTP from "@vicstack/http";
// or: import { HTTP } from "@vicstack/http";
c.json({ message: "Too many requests" }, HTTP.TooManyRequests); // 429HTTPmaps standard status names (OK,NotFound,TooManyRequests, …) to their numeric code, grouped by class (1xx-5xx) andas constso each value is its literal number, notnumber.HttpStatusCodeis the union of all codes;HttpStatusNameis the union of all names. Useful for typing a parameter that must be one of these codes:function respond(status: HttpStatusCode) { ... }.
Used by @vicstack/rate-limit
to return 429 with the right status name.
