UNPKG

tezx

Version:

TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, an

22 lines (21 loc) 774 B
import { Callback, ctx } from "../types/index.js"; import { Context } from "./context.js"; export interface option { status?: number; } export type onError<T> = (error: string, ctx: Context) => void; export declare class CommonHandler { /** * Register a custom 404 handler for missing routes * @param {Callback} callback - Handler function to execute when no route matches * @returns {this} - Returns current instance for chaining * * @example * // Register a custom not-found handler * app.notFound((ctx) => { * ctx.status(404).text('Custom not found message'); * }); */ notFound(callback: Callback): this; onError(callback: <T extends Record<string, any> = {}>(err: string, ctx: ctx<T>) => any): this; }