/// /// /// import type * as http from "http"; import type * as http2 from "http2"; import type { JsonValue } from "@bufbuild/protobuf"; import type { UniversalServerRequest, UniversalServerResponse } from "@bufbuild/connect/protocol"; /** * NodeHandlerFn is compatible with http.RequestListener and its equivalent * for http2. */ export type NodeHandlerFn = (request: NodeServerRequest, response: NodeServerResponse) => void; /** * A Node.js server request from the http, https, or the http2 module. */ export type NodeServerRequest = http.IncomingMessage | http2.Http2ServerRequest; /** * A Node.js server response from the http, https, or the http2 module. * Note that we are taking the liberty to patch the type of write() so * that they are compatible with each other. */ export type NodeServerResponse = (Omit | Omit) & { write(chunk: string | Uint8Array, callback?: (err: Error | null | undefined) => void): boolean; write(chunk: string | Uint8Array, encoding: BufferEncoding, callback?: (err: Error | null | undefined) => void): boolean; }; /** * Converts a UniversalServerRequest to a Node.js server request. * This function helps to implement adapters to server frameworks running * on Node.js. Please be careful using this function in your own code, as we * may have to make changes to it in the future. */ export declare function universalRequestFromNodeRequest(nodeRequest: NodeServerRequest, parsedJsonBody: JsonValue | undefined): UniversalServerRequest; /** * Writes a UniversalServerResponse to a Node.js server response. * This function helps to implement adapters to server frameworks running * on Node.js. Please be careful using this function in your own code, as we * may have to make changes to it in the future. */ export declare function universalResponseToNodeResponse(universalResponse: UniversalServerResponse, nodeResponse: NodeServerResponse): Promise;