/** * FURI - Fast Uniform Resource Identifier. * * The Fast and Furious Node.js Router. * Copyright(c) 2016, 2025 Rajinder Yadav. * * Labs DevMentor.org Corp. * This code is released as-is without warranty under the "GNU GENERAL PUBLIC LICENSE". */ import { IncomingMessage, ServerResponse } from 'node:http'; import { Socket } from "node:net"; import { ApplicationContext } from './application-context.js'; import { Furi } from './furi.js'; /** * API Version. */ export declare const API_VERSION: string; /** * Logging helper functions. */ export declare const LOG_DEBUG: (...s: string[]) => void; export declare const LOG_INFO: (...s: string[]) => void; export declare const LOG_WARN: (...s: string[]) => void; export declare const LOG_ERROR: (...s: string[]) => void; /** * Map types for different indexed access. */ export interface MapOf { [key: string]: T1; } export type QueryParamTypes = string | string[] | number; /** * Function prototype for Request Handler callback function. * * @param request: HttpRequest * @param response: HttpResponse * @return boolean | void - return false to cancel remaining handlers. * * When multiple request handlers are passed in as an array, * any one may return false to prevent the remaining handlers from getting executed. */ export type HandlerFunction = (ctx: ApplicationContext, next: () => void) => any | void; /** * Static route handler callback functions. */ export interface StaticRouteCallback { callbacks: HandlerFunction[]; } /** * Named route handler callback functions. * The 'key' is a regex string, with grouping for named segments. * the 'pathNames' is used by the fast match algorithm, when useRegex is false, * otherwise the 'key' is use to determine if a route matches. * * @see createNamedRouteSearchKey for details on how 'key' is created. * @see attachPathParamsToRequestIfExists for details on how 'params' is created. * @see fastPathMatch for how the path is matched against 'pathNames'. */ export interface NamedRouteCallback { useRegex: boolean; pathNames: string[]; key: string; params: string[]; callbacks: HandlerFunction[]; } /** * Maps URI to named params and handler callback functions. * * Matching Rules: * For URI direct matches, the callbacks will be found in uri_map. * For URI with named segments, the callbacks will be found under named_param. */ export interface RouteMap { staticRouteMap: MapOf; namedRoutePartitionMap: MapOf; } /** * Enumerated keys for HTTP Maps. The keys are used to partition * HTTP methods, to optimized lookup. */ export declare const HttpMapIndex: { MIDDLEWARE: number; GET: number; POST: number; PUT: number; PATCH: number; DELETE: number; }; /** * HTTP Request object extending Node.js IncomingMessage. */ export declare class HttpRequest extends IncomingMessage { params: MapOf; query: URLSearchParams | null; sessionData: MapOf; app: Furi | null; constructor(incomingMessage: Socket); constructor(incomingMessage: IncomingMessage); } /** * HTTP Response object extending Node.js ServerResponse. */ export declare class HttpResponse extends ServerResponse { } /** * FURI Server Configuration properties. * The properties are assigned default values, but can be overridden, * either from code or environment variables, or a '.env' file. */ export interface FuriConfig { env?: string; port?: number; host?: string; callback?: null | (() => void); } //# sourceMappingURL=types.d.ts.map