UNPKG

@mojojs/core

Version:

Real-time web framework

52 lines (51 loc) 1.33 kB
import type { MojoContext } from './types.js'; import Path from '@mojojs/path'; type AssetIndex = Record<string, string>; /** * Static file server class. */ export declare class Static { /** * Subdirectory used for all static assets. */ assetDir: string; /** * Prefix to use for all static files. */ prefix: string; /** * Directories to serve static files from, first one has the highest precedence. */ publicPaths: string[]; _assets: AssetIndex | undefined; /** * Get static asset path. */ assetPath(path: string): string; /** * Serve static files. */ dispatch(ctx: MojoContext): Promise<boolean>; /** * Get static file path with prefix. */ filePath(path: string): string; /** * Check freshness of request by comparing the `If-None-Match` and `If-Modified-Since` request headers to the `ETag` * and `Last-Modified` response headers. */ isFresh(ctx: MojoContext, options?: { etag?: string; lastModified?: Date; }): boolean; /** * Serve a specific file. */ serveFile(ctx: MojoContext, file: Path): Promise<void>; /** * Prepare static assets. */ warmup(): Promise<void>; _rangeNotSatisfiable(ctx: MojoContext): Promise<void>; } export {};