Class: BaseStaticRoute
Defined in: service-core/src/routes/BaseStaticRoute.ts:57
The BaseStaticRoute class provides a single endpoint for serving static files from a designated path on the filesystem (e.g. ./public).
Uses the path specified in the project configuration key static_files. Default is public.
Exposed endpoints:
| Name | HTTP Method | What it does |
|---|---|---|
get | GET /<base_path>/* | Serves static files from the configured static_files. |
!!Note!! that the BaseStaticRoute is not automatically registered with a server by default. You must create
your own class that extends AdminRoute and apply the desired base path with @Route().
Example
import { BaseStaticRoute, RouteDecorators } from "@rapidrest/service-core";
const { Route } = RouteDecorators;
@Route("/static")
export class StaticRoute extends BaseStaticRoute {}
Constructors
Constructor
new BaseStaticRoute():
BaseStaticRoute
Returns
BaseStaticRoute
Properties
routePrefix
protectedroutePrefix:string=""
Defined in: service-core/src/routes/BaseStaticRoute.ts:63
The URL prefix derived from @Route metadata at init time.
E.g. @Route("/app/*") → prefix = "/app". Used to strip the prefix from req.path
before resolving app page files, and to scope the dev-reload SSE endpoint.
staticDir
protectedreadonlystaticDir:string="public"
Defined in: service-core/src/routes/BaseStaticRoute.ts:67
The location of the static files to serve. Defaults to ./public.
Methods
get()
get(
req,res):Promise<any>
Defined in: service-core/src/routes/BaseStaticRoute.ts:107
Parameters
req
res
Returns
Promise<any>
init()
protectedinit():Promise<void>
Defined in: service-core/src/routes/BaseStaticRoute.ts:70
Returns
Promise<void>