Static files service that serves files from a configured root directory.
-
serve(ctx: IRequestContext): Promise<HandlerResult>
Serves the static file addressed by the request context.
Creates a static file RouteHandler.
Creates a StaticPlugin that serves static files from a configured root directory.
Static files service interface.
-
serve(ctx: IRequestContext): Promise<HandlerResult>
Serves the static file addressed by the request context, applying the same conditional-request, Range, and encoding negotiation the mounted routes use — this and the route handler are one implementation, so both honour the plugin's configuration identically.
Options for configuring the StaticPlugin.
-
cacheControl: string | ((relativePath: string) => string)
Cache-Control header configuration (default: function returning immutable for hashed assets, must-revalidate for others).
-
compressed: boolean
Enable precompressed sidecar negotiation (default: true).
-
etag: boolean
Enable ETag generation (default: true).
-
fallback: string
Fallback file to serve for missing paths when Accept includes text/html (default: undefined). Used for SPA fallback.
-
fs: IFileSystem
The filesystem to use for file operations.
-
index: string
Index file to serve when a directory is requested (default: 'index.html'). Set to empty string '' to disable index resolution.
-
maxBufferBytes: number
Maximum file size to read fully into memory (default: 1MB). Files larger than this will use streaming when available.
-
ranges: boolean
Enable Range request handling (default: true).
-
root: string
Required. The filesystem directory to serve files from.
-
urlPrefix: string
URL prefix for static routes (default: '/').
Usage
import * as Static_file_serving_plugin_for_the_Setu_TS_framework___Provides_configurable_static_file_serving_with_support_for____Conditional_requests__ETag__If_None_Match__If_Modified_Since____Range_requests__partial_content____Precompressed_sidecar_negotiation___br___gz____Directory_index_resolution___SPA_fallback___Streaming_for_large_files_ from "static-plugin/src/index.ts";