DefinedLocals
A typed set of locals with defaults.
A typed set of locals with defaults. See defineLocals.
Import#
ts
import type { DefinedLocals } from "@shadow-js/dusk/server";
Signature#
ts
interface DefinedLocals<T extends Record<string, unknown>> {
/** The defaults, frozen. Each one is set on a request that has no value for its key yet. */
readonly defaults: Readonly<T>;
/**
* Middleware that sets each default the request does not have yet. Put it first in the chain that
* reads the locals; it is harmless to run twice.
*/
readonly middleware: Middleware;
/**
* The request's locals, typed as `T`. The defaults are applied first, so an unset key reads as its
* default.
*/
of(event: RequestEvent): T;
}
Members#
| Name | Type | Description |
|---|---|---|
T |
T extends Record<string, unknown> |
|
defaults |
readonly defaults: Readonly<T> |
The defaults, frozen. Each one is set on a request that has no value for its key yet. |
middleware |
readonly middleware: Middleware |
Middleware that sets each default the request does not have yet. Put it first in the chain that reads the locals; it is harmless to run twice. |
of |
of(event: RequestEvent): T |
The request's locals, typed as T. The defaults are applied first, so an unset key reads as its default. |