@neoncitylights/typed-http
A pure TypeScript package that provides strongly typed HTTP headers, methods, and status codes. Supports the Fetch API, XmlHttpRequest
, and the Node.js HTTP module with zero-runtime overhead.
This package uses an open-source JSON dataset by WebConcepts with slight modifications, available under concepts.json
. The script to auto-generate the TypeScript files is available under generateHttpTypes.ts
. The generated files are:
httpHeaders.ts
: 248 HTTP header typeshttpMethods.ts
: 40 HTTP method typeshttpStatusCodes.ts
: 63 HTTP status code typesnpm install @neoncitylights/typed-http
Auto-generated API documentation is available.
Note: Specific HTTP headers, methods, and status codes are omitted from the API documentation for brevity. The full list of types is available in the source code.
T
: # headers.HttpHeader • sourceT
: # headers.HttpRequestHeader • sourceT
: # headers.HttpResponseHeader • sourceT
: # headers.ForbiddenHttpRequestHeader • sourceT
: # headers.ForbiddenHttpResponseHeader • sourceT
: # methods.HttpMethod • sourceT
: # statusCodes.HttpStatusCode • sourceT
: # statusCodes.HttpInfoStatusCode • sourceT
: # statusCodes.HttpSuccessStatusCode • sourceT
: # statusCodes.HttpRedirectStatusCode • sourceT
: # statusCodes.HttpClientErrorStatusCode • sourceT
: # statusCodes.HttpServerErrorStatusCode • sourceimport '@neoncitylights/typed-http/fetch';
let request = await fetch();
XmlHttpRequest
import '@neoncitylights/typed-http/xhr';
const xhr = new XMLHttpRequest();
xhr.addEventListener('load', (e) => console.log(xhr.responseText));
xhr.open('GET', 'https://www.google.com');
xhr.send();
import '@neoncitylights/typed-http/node';
This library is licensed under the MIT license (LICENSE-MIT
or http://opensource.org/licenses/MIT).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.
Generated using TypeDoc