UNPKG

@whatwg-node/server

Version:

Fetch API compliant HTTP Server adapter

15 lines (14 loc) • 825 B
import { MaybePromise } from '@whatwg-node/promise-helpers'; import { FetchAPI } from '../types.cjs'; import type { ServerAdapterPlugin } from './types.cjs'; export declare function createDefaultErrorHandler<TServerContext = {}>(ResponseCtor?: typeof Response): ErrorHandler<TServerContext>; export declare class HTTPError extends Error { status: number; message: string; headers: HeadersInit; details?: any; name: string; constructor(status: number | undefined, message: string, headers?: HeadersInit, details?: any); } export type ErrorHandler<TServerContext> = (e: any, request: Request, ctx: TServerContext, fetchAPI: FetchAPI) => MaybePromise<Response> | void; export declare function useErrorHandling<TServerContext>(onError?: ErrorHandler<TServerContext>): ServerAdapterPlugin<TServerContext>;