///
import { Server } from 'node:http';
import type { Request } from './request.js';
import type { Response } from './response.js';
import type { ErrorHandler } from './onError.js';
import type { Middleware, Handler, NextFunction, UseMethodParams } from '@tinyhttp/router';
import { Router } from '@tinyhttp/router';
import { AppConstructor, AppRenderOptions, AppSettings, TemplateEngine } from './types.js';
import { TemplateEngineOptions } from './index.js';
/**
* `App` class - the starting point of tinyhttp app.
*
* With the `App` you can:
* * use routing methods and `.use(...)`
* * set no match (404) and error (500) handlers
* * configure template engines
* * store data in locals
* * listen the http server on a specified port
*
* In case you use TypeScript, you can pass custom types to this class because it is also a generic class.
*
* Example:
*
* ```ts
* interface CoolReq extends Request {
* genericsAreDope: boolean
* }
*
* const app = App()
* ```
*/
export declare class App extends Router {
#private;
middleware: Middleware[];
locals: Record;
noMatchHandler: Handler;
onError: ErrorHandler;
settings: AppSettings;
engines: Record;
applyExtensions: (req: Request, res: Response, next: NextFunction) => void;
attach: (req: Req, res: Res) => void;
cache: Record;
constructor(options?: AppConstructor);
/**
* Set app setting
* @param setting setting name
* @param value setting value
*/
set(setting: K, value: AppSettings[K]): this;
/**
* Enable app setting
* @param setting Setting name
*/
enable(setting: K): this;
/**
* Check if setting is enabled
* @param setting Setting name
* @returns
*/
enabled(setting: K): boolean;
/**
* Disable app setting
* @param setting Setting name
*/
disable(setting: K): this;
/**
* Return the app's absolute pathname
* based on the parent(s) that have
* mounted it.
*
* For example if the application was
* mounted as `"/admin"`, which itself
* was mounted as `"/blog"` then the
* return value would be `"/blog/admin"`.
*
*/
path(): string;
/**
* Register a template engine with extension
*/
engine(ext: string, fn: TemplateEngine): this;
/**
* Render a template
* @param file What to render
* @param data data that is passed to a template
* @param options Template engine options
* @param cb Callback that consumes error and html
*/
render(name: string, data: Record, options: AppRenderOptions, cb: (err: unknown, html?: unknown) => void): void;
use(...args: UseMethodParams): this;
route(path: string): App;
/**
* Extends Req / Res objects, pushes 404 and 500 handlers, dispatches middleware
* @param req Req object
* @param res Res object
*/
handler(req: Req, res: Res, next?: NextFunction): void;
/**
* Creates HTTP server and dispatches middleware
* @param port server listening port
* @param Server callback after server starts listening
* @param host server listening host
*/
listen(port?: number, cb?: () => void, host?: string): Server;
}
//# sourceMappingURL=app.d.ts.map