@whatwg-node/server
Version:
Fetch API compliant HTTP Server adapter
35 lines (34 loc) • 1.41 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { IncomingMessage, ServerResponse } from 'node:http';
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
import { Socket } from 'node:net';
import type { Readable } from 'node:stream';
import type { ServerAdapterPlugin } from '../plugins/types.js';
interface NodeServerContext {
req: NodeRequest;
res?: NodeResponse;
}
export declare function useNodeAdapter(): ServerAdapterPlugin<NodeServerContext>;
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 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 normalizeNodeRequest(nodeRequest: NodeRequest, RequestCtor: typeof Request): Request;
export declare function sendNodeResponse(fetchResponse: Response, serverResponse: NodeResponse): Promise<void> | undefined;
export {};