UNPKG

@stacksjs/stx

Version:

A performant UI Framework. Powered by Bun.

35 lines 1.53 kB
import type { Server } from 'bun'; import type { StxOptions } from './types'; /** * Serve a directory of stx templates and markdown files * This is the main function for programmatic usage */ export declare function serve(options?: ServeOptions): Promise<ServeResult>; /** * Serve a single stx or markdown file */ export declare function serveFile(filePath: string, options?: Omit<ServeOptions, 'root'>): Promise<ServeResult>; /** * Create a middleware function */ export declare function createMiddleware(handler: (request: Request, next: () => Response | Promise<Response>) => Response | Promise<Response>): (request: Request, next: () => Response | Promise<Response>) => Response | Promise<Response>; /** * Helper to create a route handler */ export declare function createRoute(handler: (request: Request) => Response | Promise<Response>): (request: Request) => Response | Promise<Response>; export declare interface ServeOptions { port?: number root?: string stxOptions?: StxOptions watch?: boolean onRequest?: (request: Request) => Response | Promise<Response> | null | undefined routes?: Record<string, (request: Request) => Response | Promise<Response>> middleware?: Array<(request: Request, next: () => Response | Promise<Response>) => Response | Promise<Response>> on404?: (request: Request) => Response | Promise<Response> onError?: (error: Error, request: Request) => Response | Promise<Response> } export declare interface ServeResult { server: Server<any> stop: () => void url: string }