function / @typed/router/Path

getSchemas

Builds combined, path-only, and query-only schemas from Path AST nodes.

Package version
1.0.0-beta.13
Category
Parameter schemas
Since
1.0.0

Import

import { getSchemas } from "@typed/router/Path";

Signatures

export declare function getSchemas<const Parts extends ReadonlyArray<PathAst>>(parts: Parts): {
    readonly pathSchema: Schema.Top;
    readonly querySchema: Schema.Struct<{
        [k: string]: Schema.Top;
    }>;
    readonly paramsSchema: Schema.StructWithRest<Schema.Struct<{
        readonly [x: string]: Schema.Top;
    }>, Schema.$Record<Schema.Record.Key, Schema.Top>[]>;
};

Why

Consumers can decode the exact projection they need without reparsing the route.

Ownership and lifetime

getSchemas constructs and returns immutable Effect Schema values immediately. Any services are required later by the Effect that executes those Schemas.

Source