import type { AnySyncMiddleware, ErrorMiddleware, Middleware, MiddlewareResult, OptionsResponse, SpecialNextParam } from './shared.js'; /** * MiddlewareIndexed class that implements Middleware. * @template T * @template TMiddleware * @template TSpecialNextParam */ export declare class MiddlewareIndexed, TSpecialNextParam extends string | undefined = SpecialNextParam> implements Middleware { private getIndexKey; readonly name?: string; protected _delegate: Middleware; /** * Constructor for MiddlewareIndexed. * @param {function} getIndexKey - Function to get the index key. * @param {string} [name] - Optional name for the middleware. */ constructor(getIndexKey: (...args: T) => string, name?: string); /** * Get the keys from the index. * @returns {string[]} Array of keys. */ protected getKeys(): string[]; protected readonly index: Record & { ''?: ErrorMiddleware; }; /** * Use middleware for a specific key. * @param {string|null} key - The key for the middleware. * @param {AnySyncMiddleware} middleware - The middleware to use. * @returns {this} The current instance. */ useMiddleware(key: null, middleware: Middleware): this; useMiddleware(key: '', middleware: ErrorMiddleware): this; useMiddleware(key: string, middleware: TMiddleware): this; /** * Use an error handler. * @param {function} handler - The error handler function. * @returns {this} The current instance. */ useError(handler: ((error: Error | OptionsResponse, ...args: T) => unknown)): this; /** * Process the request. * @template X * @param {...T} req - The request parameters. * @returns {X} The result of the process. */ process(...req: T): X; /** * Handle an error. * @param {Error|OptionsResponse} error - The error to handle. * @param {...T} req - The request parameters. * @returns {MiddlewareResult} The result of the error handling. */ handleError(error: Error | OptionsResponse, ...req: T): MiddlewareResult; /** * Handle the request. * @param {...T} req - The request parameters. * @returns {MiddlewareResult} The result of the handling. */ handle(...req: T): MiddlewareResult; }