/** * This file was generated by @pikku/cli@0.12.89 */ /** * HTTP-specific type definitions for tree-shaking optimization */ import { AssertHTTPWiringParams } from '@pikku/core/http'; import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware, PikkuFunctionConfig } from '../function/pikku-function-types.gen.js'; import type { CoreHTTPFunctionWiring, HTTPMethod, HTTPRouteBaseConfig } from '@pikku/core/http'; /** * Type definition for HTTP API wirings with type-safe path parameters. * Supports both authenticated and unauthenticated functions. * * @template In - Input type for the HTTP wiring * @template Out - Output type for the HTTP wiring * @template Route - String literal type for the HTTP path (e.g., "/users/:id") */ type HTTPWiring = CoreHTTPFunctionWiring, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware>; /** * Registers an HTTP wiring with the Pikku framework. * * @template In - Input type for the HTTP wiring * @template Out - Output type for the HTTP wiring * @template Route - String literal type for the HTTP path (e.g., "/users/:id") * @param httpWiring - HTTP wiring definition with handler, method, and optional middleware */ export declare const wireHTTP: (httpWiring: HTTPWiring & AssertHTTPWiringParams) => void; /** * Registers HTTP middleware either globally or for a specific route pattern. * * When a string route pattern is provided along with middleware, the middleware * is applied only to that route. Otherwise, if an array is provided, it is treated * as global middleware (applied to all routes). * * @param routeOrMiddleware - Either a global middleware array or a route pattern string * @param middleware - The middleware array to apply when a route pattern is specified * * @example * ```typescript * // Add global HTTP middleware * addHTTPMiddleware([authMiddleware, loggingMiddleware]) * * // Add route-specific middleware * addHTTPMiddleware('/api/admin/*', [adminAuthMiddleware]) * ``` */ export declare const addHTTPMiddleware: (routeOrMiddleware: PikkuMiddleware[] | string, middleware?: PikkuMiddleware[]) => void; /** * Route configuration for wireHTTPRoutes with proper typing */ type HTTPRouteConfig = HTTPRouteBaseConfig & { method: HTTPMethod; route: string; func: PikkuFunctionConfig; auth?: boolean; middleware?: PikkuMiddleware[]; sse?: boolean; }; /** * Typed route map for wireHTTPRoutes */ type TypedHTTPRouteMap = { [key: string]: HTTPRouteConfig | TypedHTTPRouteMap | TypedHTTPRouteContract; }; /** * Typed route contract for defineHTTPRoutes */ type TypedHTTPRouteContract = TypedHTTPRoutesGroupConfig & { routes: T; }; /** * Group config with typed middleware */ type TypedHTTPRoutesGroupConfig = { basePath?: string; tags?: string[]; auth?: boolean; middleware?: PikkuMiddleware[]; }; /** * Full config for wireHTTPRoutes */ type TypedWireHTTPRoutesConfig = TypedHTTPRoutesGroupConfig & { routes: TypedHTTPRouteMap | HTTPRouteConfig[]; }; /** * Type-safe helper for defining route contracts that can be composed. */ export declare function defineHTTPRoutes(routes: T): TypedHTTPRouteContract; export declare function defineHTTPRoutes(config: TypedHTTPRoutesGroupConfig & { routes: T; }): TypedHTTPRouteContract; /** * Wires multiple HTTP routes from a nested map or array configuration. */ export declare const wireHTTPRoutes: (config: TypedWireHTTPRoutesConfig) => void; export {};