@neoncitylights/typed-http
Version:
Provides strongly typed HTTP header names. Supports the Fetch API, XmlHttpRequest, and the Node.js HTTP module with zero-runtime overhead.
24 lines (20 loc) • 582 B
TypeScript
import { HttpHeader } from 'httpHeaders';
import { HttpMethod } from 'httpMethods';
import { HttpStatusCode } from 'httpStatusCodes';
declare global {
interface Headers {
append(name: HttpHeader, value: string): void;
delete(name: HttpHeader): void;
get(name: HttpHeader): string | null;
has(name: HttpHeader): boolean;
set(name: HttpHeader, value: string): void;
keys(): IterableIterator<Lowercase<HttpHeader>>;
values(): IterableIterator<string>;
}
interface RequestInit {
method: HttpMethod;
}
interface Response {
readonly status: HttpStatusCode;
}
}