interface / @typed/router

Route

A pipeable route value containing syntax, normalized path, and Effect Schemas.

Package version
1.0.0-beta.7
Category
Route contracts
Since
1.0.0

Import

import { Route } from "@typed/router";

Signatures

export interface Route<P extends string, S extends Schema.Codec<any, Path.Params<P>, any, any> = Schema.Codec<Path.Params<P>>> extends Pipeable {
    readonly ast: AST.RouteAst;
    readonly path: P;
    readonly paramsSchema: S;
    readonly pathSchema: Schema.Codec<Path.PathParams<P>>;
    readonly querySchema: Schema.Codec<Path.QueryParams<P>>;
}
export declare namespace Route {
    type Any = Route<any, any>;
    type Path<T> = T extends Route<infer P, any> ? P : never;
    type Schema<T> = T extends Route<any, infer S> ? S : never;
    type Type<T> = T extends Route<any, infer S> ? S["Type"] : never;
    type Params<T> = T extends Route<infer P, infer _S> ? Path.Params<P> : never;
    type DecodingServices<T> = T extends Route<any, infer S> ? S["DecodingServices"] : never;
    type EncodingServices<T> = T extends Route<any, infer S> ? S["EncodingServices"] : never;
    type PathType<T extends Any> = T["pathSchema"]["Type"];
    type QueryType<T extends Any> = T["querySchema"]["Type"];
}

Why

Matching and parameter decoding share one immutable source of truth.

Ownership and lifetime

A Route value retains its AST and memoized derived values until that Route becomes unreachable; it owns no Scope.

Property: ast

The immutable Route AST compiled by Matcher.

Property: ast: Why

Advanced composition can inspect structure without reparsing the formatted path.

Property: ast: Ownership and lifetime

The Route retains its ast value for the Route’s lifetime. Reading it performs no acquisition; Codec services are required only when a schema is executed.

Property: paramsSchema

The Effect Schema for the route’s combined decoded parameters.

Property: paramsSchema: Why

Matcher handlers receive the schema’s Type and service/error behavior exactly.

Property: paramsSchema: Ownership and lifetime

The Route retains its paramsSchema value for the Route’s lifetime. Reading it performs no acquisition; Codec services are required only when a schema is executed.

Property: path

The normalized route string derived from this Route’s AST.

Property: path: Why

Matcher registration and links use one memoized formatting result.

Property: path: Ownership and lifetime

The Route retains its path value for the Route’s lifetime. Reading it performs no acquisition; Codec services are required only when a schema is executed.

Property: pathSchema

The Effect Schema for decoded path parameters only.

Property: pathSchema: Why

Handlers and tools can validate path values independently of query input.

Property: pathSchema: Ownership and lifetime

The Route retains its pathSchema value for the Route’s lifetime. Reading it performs no acquisition; Codec services are required only when a schema is executed.

Property: querySchema

The Effect Schema for decoded query parameters only.

Property: querySchema: Why

Query parsing policy remains available separately from path decoding.

Property: querySchema: Ownership and lifetime

The Route retains its querySchema value for the Route’s lifetime. Reading it performs no acquisition; Codec services are required only when a schema is executed.

Members

  • Route.Any

    A Route with intentionally widened path and schema parameters.

  • Route.DecodingServices

    Extracts services required to decode a Route’s parameters.

  • Route.EncodingServices

    Extracts services required to encode a Route’s parameters.

  • Route.Params

    Combines decoded path and query parameter fields for a route string.

  • Route.Path

    Extracts the literal path string type from a Route.

  • Route.PathType

    Extracts the decoded path-only parameter record from a Route.

  • Route.QueryType

    Extracts the decoded query-only parameter record from a Route.

  • Route.Schema

    Extracts the combined parameter Codec from a Route.

  • Route.Type

    Extracts the decoded parameter type from a Route.

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source