UNPKG

@whatwg-node/server

Version:

Fetch API compliant HTTP Server adapter

33 lines (32 loc) 1.54 kB
/// <reference types="node" /> /// <reference types="node" /> /// <reference types="node" /> /// <reference types="node" /> import { IncomingMessage, ServerResponse } from 'node:http'; import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2'; import type { Socket } from 'node:net'; import type { Readable } from 'node:stream'; import { FetchEvent } from './types'; export declare function isAsyncIterable(body: any): body is AsyncIterable<any>; export interface NodeRequest { protocol?: string; hostname?: string; body?: any; url?: string; originalUrl?: string; method?: string; headers?: any; req?: IncomingMessage | Http2ServerRequest; raw?: IncomingMessage | Http2ServerRequest; socket?: Socket; query?: any; } export type NodeResponse = ServerResponse | Http2ServerResponse; export declare function normalizeNodeRequest(nodeRequest: NodeRequest, RequestCtor: typeof Request): Request; export declare function isReadable(stream: any): stream is Readable; export declare function isNodeRequest(request: any): request is NodeRequest; export declare function isServerResponse(stream: any): stream is NodeResponse; export declare function isReadableStream(stream: any): stream is ReadableStream; export declare function isFetchEvent(event: any): event is FetchEvent; export declare function sendNodeResponse({ headers, status, statusText, body }: Response, serverResponse: NodeResponse): Promise<void>; export declare function isRequestInit(val: unknown): val is RequestInit;