Examples

Example 1

import { StaticPlugin } from '@setu-ts/static-plugin';

app.register(StaticPlugin({
  root: './public',
  urlPrefix: '/assets',
}));

Classes

c
StaticFilesService(options: StaticPluginOptions)

Static files service that serves files from a configured root directory.

Functions

f
StaticPlugin(options: StaticPluginOptions): IPlugin

Creates a StaticPlugin that serves static files from a configured root directory.

Interfaces

I
IStaticFiles

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.

Type Aliases

T
StaticPluginOptions = { root: string; fs?: IFileSystem; urlPrefix?: string; index?: string; fallback?: string; cacheControl?: string | ((relativePath: string) => string); etag?: boolean; ranges?: boolean; compressed?: boolean; maxBufferBytes?: number; }

Options for configuring the StaticPlugin.

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";