import { H as HandlerContext, a as HandlerUtility, R as RouteHandler, C as ComposeOptions, N as NextRequest } from './index-Dy6hR3v2.js'; export { A as AuthOptions, b as CorsOptions, L as LoggingOptions, c as RateLimitOptions, l as RateLimitStore, S as Schema, V as ValidateOptions, d as createRateLimiter, w as withAuth, e as withCors, f as withLogging, g as withMultiValidation, h as withOptionalAuth, i as withRateLimit, j as withTiming, k as withValidation } from './index-Dy6hR3v2.js'; /** * Compose multiple utilities into a single route handler. * * @example * ```ts * import { compose, withCors, withAuth, withRateLimit } from "next-route-compose"; * * export const GET = compose( * withCors({ origin: "*" }), * withAuth({ verify: (ctx) => verifyToken(ctx.request) }), * withRateLimit({ limit: 100, window: 60 }) * )(async (ctx) => { * return Response.json({ user: ctx.user }); * }); * ``` */ declare function compose(...utilities: HandlerUtility[]): (handler: RouteHandler, options?: ComposeOptions) => (request: NextRequest) => Promise; /** * Create a handler with a fluent builder API. * * @example * ```ts * import { createHandler, withCors, withAuth } from "next-route-compose"; * * export const GET = createHandler() * .use(withCors({ origin: "*" })) * .use(withAuth({ verify: verifyToken })) * .handle(async (ctx) => { * return Response.json({ user: ctx.user }); * }); * ``` */ declare function createHandler(): { /** * Add a utility to the handler chain. */ use(utility: HandlerUtility): /*elided*/ any; /** * Set the final handler and return the composed route handler. */ handle(handler: RouteHandler, options?: ComposeOptions): (request: NextRequest) => Promise; }; /** * Base error class for next-route-compose errors. */ declare class RouteComposeError extends Error { readonly code: string; readonly statusCode: number; constructor(message: string, code: string, statusCode?: number); /** * Convert error to a JSON Response. */ toResponse(): Response; } /** * Error thrown when authentication fails. */ declare class UnauthorizedError extends RouteComposeError { constructor(message?: string); } /** * Error thrown when access is forbidden. */ declare class ForbiddenError extends RouteComposeError { constructor(message?: string); } /** * Error thrown when rate limit is exceeded. */ declare class RateLimitError extends RouteComposeError { readonly retryAfter?: number | undefined; constructor(message?: string, retryAfter?: number | undefined); toResponse(): Response; } /** * Error thrown when validation fails. */ declare class ValidationError extends RouteComposeError { readonly details?: unknown | undefined; constructor(message?: string, details?: unknown | undefined); toResponse(): Response; } /** * Error thrown for bad requests. */ declare class BadRequestError extends RouteComposeError { constructor(message?: string); } /** * Error thrown when a resource is not found. */ declare class NotFoundError extends RouteComposeError { constructor(message?: string); } /** * Default error handler that converts errors to JSON responses. */ declare function defaultErrorHandler(error: unknown): Response; export { BadRequestError, ComposeOptions, ForbiddenError, HandlerContext, HandlerUtility, NextRequest, NotFoundError, RateLimitError, RouteComposeError, RouteHandler, UnauthorizedError, ValidationError, compose, createHandler, defaultErrorHandler };