validateRouting
Validates the declarative routing and compiles every pattern.
Validates the declarative routing and compiles every pattern. Throws at the first problem, naming
the rule (redirects[2].destination), so a configuration error is found when the build starts, and
the same check runs again when the server starts.
Import#
ts
import { validateRouting } from "@shadow-js/dusk/server";
Signature#
ts
function validateRouting(
input: RoutingConfig,
options: RoutingValidationOptions = {},
): ResolvedRouting
Parameters#
| Name | Description |
|---|---|
input |
The routing as written in dusk.config.ts. |
options |
The trusted origins of absolute redirects. |
Returns#
The validated routing.
Throws#
- TypeError with the place and the reason; a suggestion for an unknown key.
Examples#
ts
validateRouting({ redirects: [{ source: "/old", destination: "/new", permanent: true }] }, {}).redirects[0]?.status; // 308