/// import { t } from 'wint-js'; import { Context } from './types'; import { Server, ServeOptions } from 'bun'; import { Routes } from './core/routes'; import { ws } from './core/ws'; export interface AppOptions { router?: t.FastWint; /** * Serve options */ serve?: Partial; /** * Directories that contain routes files */ routes?: string[]; /** * Fallback if routes are not found */ fallback?: (c: Context) => any; /** * The config file name */ config?: string; /** * Auto prefix routes like file system routing */ autoprefix?: boolean; } /** * The main function to import */ export interface MainFunction { (app: App): Routes | Promise>; } export declare class App { /** * Record of routes */ routes: Routes; /** * The current running server */ server: Server; /** * All app options */ readonly options: Required; /** * Initialize an app */ constructor(options?: AppOptions); /** * Create an app with provided routes record */ static create(routes: Routes, options?: AppOptions): App; /** * Create and build an app with provided routes record */ static build(routes: Routes, options?: AppOptions): Promise; /** * Create and serve an app with provided routes record */ static serve(routes: Routes, options?: AppOptions): Promise; /** * Extend routes */ put(routes: Routes): this; /** * Start the server. Only works in Bun */ boot(): this; /** * WebSocket handlers list */ readonly wsList: ws.Route[]; ws(f: ws.Route): this; /** * Load routes from options. */ loadRoutes(): Promise; /** * Register all routes from directories and returns the serve options */ build(serve?: boolean): Promise; /** * Check whether server is a dev server */ get dev(): boolean; /** * Set development mode */ set dev(value: boolean); /** * Log all routes registered */ logRoutes(): void; /** * Load routes from a directory */ route(dir: string): Promise; } /** * Shorthand for `new App().build(true)`. */ export declare const init: (options: AppOptions) => Promise; /** * Shorthand for `new App().build()` */ export declare const build: (options: AppOptions) => Promise; /** * Mark a function as async to get detected by the compiler */ export declare const wrapAsync: (f: T) => T; export * from './core/routes'; export * from './core/config'; export * from './core/ws'; export * from './client'; export * from './core/func'; export * from './types'; export * from './types/basic'; export * from './types/config'; export default App;