UNPKG

edgespec

Version:

Write Winter-CG compatible routes with filesystem routing and tons of features

70 lines (65 loc) 2.46 kB
import { z } from 'zod'; import { M as Middleware } from '../edge-spec-CQZ1EUiH.js'; export { a as MiddlewareChain } from '../edge-spec-CQZ1EUiH.js'; import 'type-fest'; import 'openapi3-ts/oas31'; interface HttpException { status: number; message?: string; _isHttpException: true; } declare abstract class EdgeSpecMiddlewareError extends Error implements HttpException { message: string; status: number; _isHttpException: true; constructor(message: string, status?: number); } declare class MethodNotAllowedError extends EdgeSpecMiddlewareError { constructor(allowedMethods: readonly string[]); } declare class NotFoundError extends EdgeSpecMiddlewareError { constructor(message: string); } declare abstract class BadRequestError extends EdgeSpecMiddlewareError { constructor(message: string); } declare class InvalidQueryParamsError extends BadRequestError { constructor(message: string); } declare class InvalidContentTypeError extends BadRequestError { constructor(message: string); } declare class InputParsingError extends BadRequestError { constructor(message: string); } declare class InputValidationError extends BadRequestError { constructor(error: z.ZodError<any>); } declare class ResponseValidationError extends EdgeSpecMiddlewareError { constructor(error: z.ZodError<any>); } type Logger = { debug: (...args: any[]) => void; info: (...args: any[]) => void; warn: (...args: any[]) => void; error: (...args: any[]) => void; }; /** * Attaches a provided logger to ctx.logger. * `ctx.logger` is used by internal EdgeSpec middleware when provided (instead of `console`). */ declare const createWithLogger: <L extends Logger>(logger: L) => Middleware<{}, { logger: L; }>; interface CreateWithDefaultExceptionHandlingOptions { coloredLogs?: boolean; logWhen?: (status: number, error: unknown) => boolean; includeStackTraceInResponse?: boolean; } /** * */ declare const createWithDefaultExceptionHandling: ({ coloredLogs, logWhen, includeStackTraceInResponse, }?: CreateWithDefaultExceptionHandlingOptions) => Middleware<{ logger?: Logger; }>; export { BadRequestError, EdgeSpecMiddlewareError, type HttpException, InputParsingError, InputValidationError, InvalidContentTypeError, InvalidQueryParamsError, type Logger, MethodNotAllowedError, Middleware, NotFoundError, ResponseValidationError, createWithDefaultExceptionHandling, createWithLogger };