Skip to main content Link Search Menu Expand Document (external link)

RouteHandler overview

Added in v1.0.0


Table of contents


utils

CurrentParams (interface)

Signature

export interface CurrentParams<I extends Router.MatchInput.Any> {
  readonly params: Router.MatchInput.Success<I>
  readonly queryParams: URLSearchParams
}

Added in v1.0.0

Handler (type alias)

Signature

export type Handler<Route extends Router.MatchInput.Any, E, R> = Effect.Effect<
  ServerResponse,
  E,
  R | Router.CurrentRoute | CurrentParams<Route> | Navigation.Navigation | ServerRequest
>

Added in v1.0.0

RouteHandler (interface)

Signature

export interface RouteHandler<Route extends Router.MatchInput.Any, E, R> {
  readonly method: Method | "*"
  readonly route: Route
  readonly handler: Handler<Route, E, R>
}

Added in v1.0.0

RouteHandler (namespace)

Added in v1.0.0

Any (type alias)

Signature

export type Any = RouteHandler<Router.MatchInput.Any, any, any>

Added in v1.0.0

Context (type alias)

Signature

export type Context<T> =
  T extends RouteHandler<infer I, any, infer R>
    ? Exclude<Exclude<R, CurrentParams<I>> | Router.MatchInput.Context<I>, Navigation.Navigation>
    : never

Added in v1.0.0

Error (type alias)

Signature

export type Error<T> =
  T extends RouteHandler<infer I, infer E, any> ? E | Router.MatchInput.Error<I> | RouteNotMatched : never

Added in v1.0.0

RouteNotMatched (class)

Signature

export declare class RouteNotMatched

Added in v1.0.0

all

Signature

export declare const all: <I extends Router.MatchInput.Any, E, R>(
  route: I,
  handler: Handler<I, E, R>
) => RouteHandler<I, E, R>

Added in v1.0.0

catchAll

Signature

export declare const catchAll: {
  <E2, E3, R3>(
    onError: (error: E2) => Effect.Effect<ServerResponse, E3, R3>
  ): <R extends Router.MatchInput.Any, R2>(handler: RouteHandler<R, E2, R2>) => RouteHandler<R, E3, R3 | R2>
  <R extends Router.MatchInput.Any, E2, R2, E3, R3>(
    handler: RouteHandler<R, E2, R2>,
    onError: (error: E2) => Effect.Effect<ServerResponse, E3, R3>
  ): RouteHandler<R, E3, R2 | R3>
}

Added in v1.0.0

catchAllCause

Signature

export declare const catchAllCause: {
  <E2, E3, R3>(
    onCause: (cause: Cause.Cause<E2>) => Effect.Effect<ServerResponse, E3, R3>
  ): <R extends Router.MatchInput.Any, R2>(handler: RouteHandler<R, E2, R2>) => RouteHandler<R, E3, R3 | R2>
  <R extends Router.MatchInput.Any, E2, R2, E3, R3>(
    handler: RouteHandler<R, E2, R2>,
    onCause: (cause: Cause.Cause<E2>) => Effect.Effect<ServerResponse, E3, R3>
  ): RouteHandler<R, E3, R2 | R3>
}

Added in v1.0.0

catchTag

Signature

export declare const catchTag: {
  <E2, const Tag extends E2 extends { readonly _tag: string } ? E2["_tag"] : never, E3, R3>(
    tag: Tag,
    onError: (error: Extract<E2, { readonly _tag: Tag }>) => Effect.Effect<ServerResponse, E3, R3>
  ): <R extends Router.MatchInput.Any, R2>(
    handler: RouteHandler<R, E2, R2>
  ) => RouteHandler<R, E3 | Exclude<E2, { readonly _tag: Tag }>, R3 | R2>
  <
    R extends Router.MatchInput.Any,
    E2,
    R2,
    const Tag extends E2 extends { readonly _tag: string } ? E2["_tag"] : never,
    E3,
    R3
  >(
    handler: RouteHandler<R, E2, R2>,
    tag: Tag,
    onError: (error: Extract<E2, { readonly _tag: Tag }>) => Effect.Effect<ServerResponse, E3, R3>
  ): RouteHandler<R, E3 | Exclude<E2, { readonly _tag: Tag }>, R2 | R3>
}

Added in v1.0.0

currentParamsLayer

Signature

export declare function currentParamsLayer<I extends Router.MatchInput.Any>(
  params: CurrentParams<I>
): Layer.Layer<CurrentParams<I>>

Added in v1.0.0

delete

Signature

export declare const delete: <I extends Router.MatchInput.Any, E, R>(route: I, handler: Handler<I, E, R>) => RouteHandler<I, E, R>

Added in v1.0.0

get

Signature

export declare const get: <I extends Router.MatchInput.Any, E, R>(
  route: I,
  handler: Handler<I, E, R>
) => RouteHandler<I, E, R>

Added in v1.0.0

getCurrentParams

Signature

export declare function getCurrentParams<I extends Router.MatchInput.Any>(
  _route: I
): Effect.Effect<CurrentParams<I>, never, CurrentParams<I>>

Added in v1.0.0

getCurrentParamsOption

Signature

export declare const getCurrentParamsOption: Effect.Effect<
  Option.Option<CurrentParams<Router.MatchInput.Any>>,
  never,
  never
>

Added in v1.0.0

getUrlFromServerRequest

Signature

export declare function getUrlFromServerRequest(request: ServerRequest): URL

Added in v1.0.0

Signature

export declare const head: <I extends Router.MatchInput.Any, E, R>(
  route: I,
  handler: Handler<I, E, R>
) => RouteHandler<I, E, R>

Added in v1.0.0

make

Signature

export declare const make: (
  method: Method | "*"
) => <I extends Router.MatchInput.Any, E, R>(route: I, handler: Handler<I, E, R>) => RouteHandler<I, E, R>

Added in v1.0.0

options

Signature

export declare const options: <I extends Router.MatchInput.Any, E, R>(
  route: I,
  handler: Handler<I, E, R>
) => RouteHandler<I, E, R>

Added in v1.0.0

patch

Signature

export declare const patch: <I extends Router.MatchInput.Any, E, R>(
  route: I,
  handler: Handler<I, E, R>
) => RouteHandler<I, E, R>

Added in v1.0.0

post

Signature

export declare const post: <I extends Router.MatchInput.Any, E, R>(
  route: I,
  handler: Handler<I, E, R>
) => RouteHandler<I, E, R>

Added in v1.0.0

put

Signature

export declare const put: <I extends Router.MatchInput.Any, E, R>(
  route: I,
  handler: Handler<I, E, R>
) => RouteHandler<I, E, R>

Added in v1.0.0

toHttpApp

Signature

export declare function toHttpApp<I extends RouteHandler.Any>(
  { handler, route: input }: I,
  parent?: Router.CurrentRoute
): Default<RouteHandler.Error<I>, RouteHandler.Context<I>>

Added in v1.0.0

toPlatformRoute

Signature

export declare function toPlatformRoute<I extends RouteHandler.Any>(
  handler: I
): <E, R>(
  self: PlatformRouter.Router<E, R>
) => PlatformRouter.Router<E | RouteHandler.Error<I>, R | RouteHandler.Context<I>>

Added in v1.0.0