RouteBuilder
Type Parameters
Type Parameter |
---|
TParams extends RouteParams |
Properties
Property | Type | Description |
---|---|---|
~def | RouteDefInner <TParams > | Internal |
Methods
body()
body<
$Parser
>(schema
):RouteBuilder
<object
>
Register a parser for the request body.
[Overrides]
Type Parameters
Type Parameter |
---|
$Parser extends Parser |
Parameters
Parameter | Type |
---|---|
schema | $Parser |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | InferIn <$Parser > |
BodyOut | Infer <$Parser > |
HeadersReqIn | TParams ["HeadersReqIn" ] |
HeadersReqOut | TParams ["HeadersReqOut" ] |
InferredParams | TParams ["InferredParams" ] |
Meta | TParams ["Meta" ] |
Methods | TParams ["Methods" ] |
OutputIn | TParams ["OutputIn" ] |
OutputOut | TParams ["OutputOut" ] |
ParamsIn | TParams ["ParamsIn" ] |
ParamsOut | TParams ["ParamsOut" ] |
Path | TParams ["Path" ] |
Providers | TParams ["Providers" ] |
QueryIn | TParams ["QueryIn" ] |
QueryOut | TParams ["QueryOut" ] |
State | TParams ["State" ] |
handle()
handle(
handler
):CompiledRoute
<TParams
>
Defines the request handler.
This concludes the route building process and produces a CompiledRoute
instance.
Parameters
Parameter | Type |
---|---|
handler | HandlerFunction <TParams > |
Returns
CompiledRoute
<TParams
>
headers()
headers<
$Parser
>(schema
):RouteBuilder
<object
>
Register a parser for the request headers.
[Overrides]
Type Parameters
Type Parameter |
---|
$Parser extends Parser |
Parameters
Parameter | Type |
---|---|
schema | $Parser |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | TParams ["BodyIn" ] |
BodyOut | TParams ["BodyOut" ] |
HeadersReqIn | InferIn <$Parser > |
HeadersReqOut | Infer <$Parser > |
InferredParams | TParams ["InferredParams" ] |
Meta | TParams ["Meta" ] |
Methods | TParams ["Methods" ] |
OutputIn | TParams ["OutputIn" ] |
OutputOut | TParams ["OutputOut" ] |
ParamsIn | TParams ["ParamsIn" ] |
ParamsOut | TParams ["ParamsOut" ] |
Path | TParams ["Path" ] |
Providers | TParams ["Providers" ] |
QueryIn | TParams ["QueryIn" ] |
QueryOut | TParams ["QueryOut" ] |
State | TParams ["State" ] |
meta()
meta<
TMeta
>(meta
?):RouteBuilder
<object
>
Add arbitrary metadata to the route.
This can act as an escape hatch for declaring information on routes that doesn't
fit into existing webroute
constructs.
Meta is shallow merged, so conflicting keys will override previous keys.
Use at your own discretion.
[Appends: Shallow Merge]
Type Parameters
Type Parameter |
---|
TMeta extends RouteMeta |
Parameters
Parameter | Type |
---|---|
meta ? | TMeta |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | TParams ["BodyIn" ] |
BodyOut | TParams ["BodyOut" ] |
HeadersReqIn | TParams ["HeadersReqIn" ] |
HeadersReqOut | TParams ["HeadersReqOut" ] |
InferredParams | TParams ["InferredParams" ] |
Meta | TMeta |
Methods | TParams ["Methods" ] |
OutputIn | TParams ["OutputIn" ] |
OutputOut | TParams ["OutputOut" ] |
ParamsIn | TParams ["ParamsIn" ] |
ParamsOut | TParams ["ParamsOut" ] |
Path | TParams ["Path" ] |
Providers | TParams ["Providers" ] |
QueryIn | TParams ["QueryIn" ] |
QueryOut | TParams ["QueryOut" ] |
State | TParams ["State" ] |
method()
method<
TMethod
>(method
):RouteBuilder
<object
>
Set the route method(s).
[Overrides]
Type Parameters
Type Parameter |
---|
TMethod extends HttpMethodInput | HttpMethodInput [] |
Parameters
Parameter | Type |
---|---|
method | TMethod |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | TParams ["BodyIn" ] |
BodyOut | TParams ["BodyOut" ] |
HeadersReqIn | TParams ["HeadersReqIn" ] |
HeadersReqOut | TParams ["HeadersReqOut" ] |
InferredParams | TParams ["InferredParams" ] |
Meta | TParams ["Meta" ] |
Methods | TMethod extends HttpMethodInput ? Uppercase <TMethod <TMethod >> : Uppercase <TMethod [number ]> |
OutputIn | TParams ["OutputIn" ] |
OutputOut | TParams ["OutputOut" ] |
ParamsIn | TParams ["ParamsIn" ] |
ParamsOut | TParams ["ParamsOut" ] |
Path | TParams ["Path" ] |
Providers | TParams ["Providers" ] |
QueryIn | TParams ["QueryIn" ] |
QueryOut | TParams ["QueryOut" ] |
State | TParams ["State" ] |
output()
output<
$Parser
>(schema
):RouteBuilder
<object
>
Register a parser for the request output (response body).
[Overrides]
Type Parameters
Type Parameter |
---|
$Parser extends Parser |
Parameters
Parameter | Type |
---|---|
schema | $Parser |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | TParams ["BodyIn" ] |
BodyOut | TParams ["BodyOut" ] |
HeadersReqIn | TParams ["HeadersReqIn" ] |
HeadersReqOut | TParams ["HeadersReqOut" ] |
InferredParams | TParams ["InferredParams" ] |
Meta | TParams ["Meta" ] |
Methods | TParams ["Methods" ] |
OutputIn | InferIn <$Parser > |
OutputOut | Infer <$Parser > |
ParamsIn | TParams ["ParamsIn" ] |
ParamsOut | TParams ["ParamsOut" ] |
Path | TParams ["Path" ] |
Providers | TParams ["Providers" ] |
QueryIn | TParams ["QueryIn" ] |
QueryOut | TParams ["QueryOut" ] |
State | TParams ["State" ] |
params()
params<
$Parser
>(schema
):RouteBuilder
<object
>
Register a parser for the request path params.
[Overrides]
Type Parameters
Type Parameter |
---|
$Parser extends Parser |
Parameters
Parameter | Type |
---|---|
schema | $Parser |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | TParams ["BodyIn" ] |
BodyOut | TParams ["BodyOut" ] |
HeadersReqIn | TParams ["HeadersReqIn" ] |
HeadersReqOut | TParams ["HeadersReqOut" ] |
InferredParams | TParams ["InferredParams" ] |
Meta | TParams ["Meta" ] |
Methods | TParams ["Methods" ] |
OutputIn | TParams ["OutputIn" ] |
OutputOut | TParams ["OutputOut" ] |
ParamsIn | InferIn <$Parser > |
ParamsOut | Infer <$Parser > |
Path | TParams ["Path" ] |
Providers | TParams ["Providers" ] |
QueryIn | TParams ["QueryIn" ] |
QueryOut | TParams ["QueryOut" ] |
State | TParams ["State" ] |
path()
path<
TPath
>(path
):RouteBuilder
<object
>
Set the route path.
If a path is already set upstream, this will append to the path.
[Appends]
Type Parameters
Type Parameter |
---|
TPath extends string |
Parameters
Parameter | Type |
---|---|
path | TPath |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | TParams ["BodyIn" ] |
BodyOut | TParams ["BodyOut" ] |
HeadersReqIn | TParams ["HeadersReqIn" ] |
HeadersReqOut | TParams ["HeadersReqOut" ] |
InferredParams | TParams ["InferredParams" ] |
Meta | TParams ["Meta" ] |
Methods | TParams ["Methods" ] |
OutputIn | TParams ["OutputIn" ] |
OutputOut | TParams ["OutputOut" ] |
ParamsIn | TParams ["ParamsIn" ] |
ParamsOut | TParams ["ParamsOut" ] |
Path | TParams ["Path" ] extends string ? `${any[any]}${TPath}` : TPath |
Providers | TParams ["Providers" ] |
QueryIn | TParams ["QueryIn" ] |
QueryOut | TParams ["QueryOut" ] |
State | TParams ["State" ] |
provide()
provide<
TProviders
>(providers
):RouteBuilder
<object
>
Registers providers which will get exposed to the handler under services
.
[Appends: Shallow Merge]
Type Parameters
Type Parameter |
---|
TProviders extends AnyProviderMap |
Parameters
Parameter | Type |
---|---|
providers | TProviders |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | TParams ["BodyIn" ] |
BodyOut | TParams ["BodyOut" ] |
HeadersReqIn | TParams ["HeadersReqIn" ] |
HeadersReqOut | TParams ["HeadersReqOut" ] |
InferredParams | TParams ["InferredParams" ] |
Meta | TParams ["Meta" ] |
Methods | TParams ["Methods" ] |
OutputIn | TParams ["OutputIn" ] |
OutputOut | TParams ["OutputOut" ] |
ParamsIn | TParams ["ParamsIn" ] |
ParamsOut | TParams ["ParamsOut" ] |
Path | TParams ["Path" ] |
Providers | { [KeyType in string | number | symbol]: ({ [K in string | number | symbol]: K extends keyof TProviders ? TProviders[K<K>] : TParams["Providers"][K] } & TProviders)[KeyType] } |
QueryIn | TParams ["QueryIn" ] |
QueryOut | TParams ["QueryOut" ] |
State | TParams ["State" ] |
query()
query<
$Parser
>(schema
):RouteBuilder
<object
>
Register a parser for the request query.
[Overrides]
Type Parameters
Type Parameter |
---|
$Parser extends Parser |
Parameters
Parameter | Type |
---|---|
schema | $Parser |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | TParams ["BodyIn" ] |
BodyOut | TParams ["BodyOut" ] |
HeadersReqIn | TParams ["HeadersReqIn" ] |
HeadersReqOut | TParams ["HeadersReqOut" ] |
InferredParams | TParams ["InferredParams" ] |
Meta | TParams ["Meta" ] |
Methods | TParams ["Methods" ] |
OutputIn | TParams ["OutputIn" ] |
OutputOut | TParams ["OutputOut" ] |
ParamsIn | TParams ["ParamsIn" ] |
ParamsOut | TParams ["ParamsOut" ] |
Path | TParams ["Path" ] |
Providers | TParams ["Providers" ] |
QueryIn | InferIn <$Parser > |
QueryOut | Infer <$Parser > |
State | TParams ["State" ] |
use()
use<
TMutations
,TResult
>(handler
):RouteBuilder
<object
>
Register a route middleware.
Middleware may update the state
context value.
It may also return a Response
early or register a request handler which will run
on the egress journey.
State return values are shallow merged.
[Appends]
Type Parameters
Type Parameter | Default type |
---|---|
TMutations extends unknown | unknown |
TResult extends void | DataResult | void |
Parameters
Parameter | Type |
---|---|
handler | UseMiddlewareInput <TParams ["ParamsOut" ], TParams ["QueryOut" ], TParams ["BodyOut" ], TParams ["HeadersReqOut" ], TParams ["State" ], TParams ["Providers" ], void | TResult > |
Returns
RouteBuilder
<object
>
Name | Type |
---|---|
BodyIn | TParams ["BodyIn" ] |
BodyOut | TParams ["BodyOut" ] |
HeadersReqIn | TParams ["HeadersReqIn" ] |
HeadersReqOut | TParams ["HeadersReqOut" ] |
InferredParams | TParams ["InferredParams" ] |
Meta | TParams ["Meta" ] |
Methods | TParams ["Methods" ] |
OutputIn | TParams ["OutputIn" ] |
OutputOut | TParams ["OutputOut" ] |
ParamsIn | TParams ["ParamsIn" ] |
ParamsOut | TParams ["ParamsOut" ] |
Path | TParams ["Path" ] |
Providers | TParams ["Providers" ] |
QueryIn | TParams ["QueryIn" ] |
QueryOut | TParams ["QueryOut" ] |
State | void extends TResult ? TParams ["State" ] & TMutations : { [KeyType in string | number | symbol]: ({ [K in string | number | symbol]: K extends keyof TResult ? TResult[K<K>] : TParams["State"][K] } & TResult)[KeyType] } |