Cell API
    Preparing search index...

    Class ServeStaticMiddleware

    Implements

    Index
    config: {
        apiPath: string;
        options: any;
        path: string;
        root: string;
        spa: boolean;
    }
    hasFrontend: boolean

    Whether there is a frontend to serve: embedded in the bundle (--single) or on disk. On Cloudflare Workers the platform serves the frontend and the worker has no copy.

    options: ServeStaticOption & Record<string, any>

    Options of the file server: a copy of cell.serve-static.options, which stays untouched.

    path: string
    priority: any = ...
    requestMatcher: RequestMatcher
    serve: Serve
    • Adds the configured headers to every file, and gives HTML files their own Cache-Control (htmlMaxAge in milliseconds, default 0) so that a new build of the page is picked up.

      Parameters

      • headers: Record<string, string> | undefined
      • htmlMaxAge: unknown

      Returns (res: OutgoingMessage, path: string) => void

    • Parameters

      • ctx: Context
      • next: () => Promise<void>

      Returns Promise<void>

    • Sets up the file server once. Cloudflare Workers allow I/O (existsSync) only while a request is handled; the application, and with it this component, starts on the first request there.

      Returns void