Stone.js API
    Preparing search index...

    Interface RouteDefinition<IncomingEventType, OutgoingResponseType>

    Represents the structure of a route definition.

    interface RouteDefinition<
        IncomingEventType extends IIncomingEvent = IIncomingEvent,
        OutgoingResponseType = unknown,
    > {
        bindings?: Record<string, IBoundModel | BindingResolver | string>;
        children?: RouteDefinition<IncomingEventType, OutgoingResponseType>[];
        defaults?: Record<string, unknown>;
        domain?: string | string[];
        excludeMiddleware?: PipeType<IncomingEventType, OutgoingResponseType>[];
        fallback?: boolean;
        handler?: MixedEventHandler<IncomingEventType, OutgoingResponseType>;
        isInternalHeader?: boolean;
        method?: HttpMethod;
        methods?: HttpMethod[];
        middleware?: MixedPipe<IncomingEventType, OutgoingResponseType>[];
        name?: string;
        path: string | string[];
        prefix?: string | false;
        protocol?: string | string[];
        protocolPolicy?: ProtocolPolicy;
        redirect?:
            | string
            | Record<string, unknown>
            | RouteDefinitionRedirect<IncomingEventType, unknown>;
        rules?: Record<string, RegExp | string>;
        strict?: boolean;
        [k: string]: unknown;
    }

    Type Parameters

    Hierarchy (View Summary)

    Indexable

    • [k: string]: unknown

      Anything a module declares on a route.

      This is deliberate, and it is what keeps the router agnostic. A route definition is the one place that describes a route, so modules declare what they need on it, validation, resource, auth, authz, and each reads back the part it owns through route.getOption(name). The router carries them and never interprets them, exactly as the kernel carries an event it knows nothing about. Naming those keys here would tie this package's public type to modules it does not depend on, and would buy nothing: an index signature already accepts every one of them.

    Index
    bindings?: Record<string, IBoundModel | BindingResolver | string>
    defaults?: Record<string, unknown>
    domain?: string | string[]
    excludeMiddleware?: PipeType<IncomingEventType, OutgoingResponseType>[]
    fallback?: boolean
    isInternalHeader?: boolean
    method?: HttpMethod
    methods?: HttpMethod[]
    middleware?: MixedPipe<IncomingEventType, OutgoingResponseType>[]
    name?: string
    path: string | string[]
    prefix?: string | false

    This route's relation to the router's global prefix.

    Unset, the global prefix applies, which is what an API route wants: /tasks under a /v1 router is /v1/tasks. false escapes it, for the routes that must not move when the API version does: a health probe is asked by a load balancer that knows no version, and a probe that changes address on a /v2 migration is a probe that goes dark. A string replaces the global prefix for this route alone, the same per-route-wins rule as strict and protocolPolicy.

    protocol?: string | string[]
    protocolPolicy?: ProtocolPolicy
    redirect?:
        | string
        | Record<string, unknown>
        | RouteDefinitionRedirect<IncomingEventType, unknown>
    rules?: Record<string, RegExp | string>
    strict?: boolean