UNPKG

servatron

Version:

Create a handler that can server static files using the NodeJS http/http2 modules, or use the inbuilt cli server to quickly run a web server.

18 lines (17 loc) 634 B
import type { IncomingMessage, ServerResponse } from 'node:http'; export interface ServatronHttpOptions { directory: string | Array<string>; spa?: boolean; spaIndex?: string; antiCors?: boolean; index?: Array<string>; resolvers?: { [pattern: string]: (filePath: string, content: Buffer, response: ServerResponse) => void; }; } /** * Create a handler that will respond to a request * with the response from a static file lookup. **/ declare const servatron: (optionsInput?: ServatronHttpOptions) => (request: IncomingMessage, response: ServerResponse) => Promise<void>; export default servatron;