index.d.ts 844 B

123456789101112131415161718192021222324252627282930313233
  1. import type { Stats } from "node:fs";
  2. import type { IncomingMessage, ServerResponse } from "node:http";
  3. declare namespace sirv {
  4. type Arrayable<T> = T | T[];
  5. export type NextHandler = () => void | Promise<void>;
  6. export type RequestHandler = (
  7. req: IncomingMessage,
  8. res: ServerResponse,
  9. next?: NextHandler,
  10. ) => void;
  11. export interface Options {
  12. dev?: boolean;
  13. etag?: boolean;
  14. maxAge?: number;
  15. immutable?: boolean;
  16. single?: string | boolean;
  17. ignores?: false | Arrayable<string | RegExp>;
  18. extensions?: string[];
  19. dotfiles?: boolean;
  20. brotli?: boolean;
  21. gzip?: boolean;
  22. onNoMatch?: (req: IncomingMessage, res: ServerResponse) => void;
  23. setHeaders?: (res: ServerResponse, pathname: string, stats: Stats) => void;
  24. }
  25. }
  26. declare function sirv(dir?: string, opts?: sirv.Options): sirv.RequestHandler;
  27. export = sirv;