UNPKG

runtime-edge

Version:

Run any Edge Function from CLI or Node.js module.

27 lines (26 loc) 1.01 kB
/// <reference types="node" /> import type { RuntimeEdge } from '../runtime-edge'; import type { IncomingMessage, ServerResponse } from 'http'; import type { Logger } from '../types'; import type { EdgeContext } from '@runtime-edge/vm'; export interface Options<T extends EdgeContext> { /** * A logger interface. If none is provided there will be no logs. */ logger?: Logger; /** * The runtime where the FetchEvent will be triggered whenever the server * receives a request. */ runtime: RuntimeEdge<T>; } /** * Creates an HHTP handler that can be used to create a Node.js HTTP server. * Whenever a request is handled it will transform it into a `dispatchFetch` * call for the given `RuntimeEdge`. Then it will transform the response * into an HTTP response. */ export declare function createHandler<T extends EdgeContext>(options: Options<T>): { handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>; waitUntil: () => Promise<unknown[]>; };