@universal-middleware/sirv
Version:
Universal static file serving middleware
23 lines (20 loc) • 753 B
TypeScript
import { Stats } from 'node:fs';
import { UniversalMiddleware } from '@universal-middleware/core';
type OnNoMatch = (req: Request) => Response | undefined | Promise<Response | undefined>;
type Arrayable<T> = T | T[];
interface ServeOptions {
dev?: boolean;
etag?: boolean;
maxAge?: number | null;
immutable?: boolean;
single?: string | boolean;
ignores?: false | Arrayable<string | RegExp>;
extensions?: string[];
dotfiles?: boolean;
brotli?: boolean;
gzip?: boolean;
onNoMatch?: OnNoMatch;
setHeaders?: (res: Response, pathname: string, stats: Stats) => void;
}
declare function serveStatic(dir?: string, opts?: ServeOptions): UniversalMiddleware;
export { type ServeOptions, serveStatic as default };