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

Router overview

Added in v1.0.0


Table of contents


combinators

toHandler

Signature

export declare const toHandler: <R extends Router<any, any>>(
  router: R,
  options?: { readonly spanPrefix?: string }
) => (u: unknown) => Stream.Stream<Router.Response, ParseError, Router.Context<R>>

Added in v1.0.0

toHandlerEffect

Signature

export declare const toHandlerEffect: <R extends Router<any, any>>(
  router: R,
  options?: { readonly spanPrefix?: string }
) => (u: unknown) => Effect.Effect<readonly any[], ParseError, Router.Context<R>>

Added in v1.0.0

toHandlerRaw

Signature

export declare const toHandlerRaw: <R extends Router<any, any>>(
  router: R
) => <Req extends Router.Request<R>>(request: Req) => Rpc.Rpc.Result<Req, Router.ContextRaw<R>>

Added in v1.0.0

toHandlerUndecoded

Signature

export declare const toHandlerUndecoded: <R extends Router<any, any>>(
  router: R
) => <Req extends Router.Request<R>>(request: Req) => Rpc.Rpc.ResultUndecoded<Req, Router.Context<R>>

Added in v1.0.0

constructors

make

Signature

export declare const make: <Rpcs extends readonly (Rpc.Rpc<any, any> | Router<any, any>)[]>(
  ...rpcs: Rpcs
) => Router<
  any,
  | Rpc.Rpc.Context<Extract<Rpcs[number], { readonly [Rpc.TypeId]: Rpc.TypeId }>>
  | Router.Context<Extract<Rpcs[number], { readonly [TypeId]: TypeId }>>
>

Added in v1.0.0

context

provideService

Signature

export declare const provideService: {
  <I, S>(
    tag: Context.Tag<I, S>,
    service: S
  ): <Reqs extends Schema.TaggedRequest.Any, R>(self: Router<Reqs, R>) => Router<Reqs, Exclude<R, I>>
  <Reqs extends Schema.TaggedRequest.Any, R, I, S>(
    self: Router<Reqs, R>,
    tag: Context.Tag<I, S>,
    service: S
  ): Router<Reqs, Exclude<R, I>>
}

Added in v1.0.0

provideServiceEffect

Signature

export declare const provideServiceEffect: {
  <I, S, E, R2>(
    tag: Context.Tag<I, S>,
    effect: Effect.Effect<S, E, R2>
  ): <Reqs extends Schema.TaggedRequest.Any, R>(self: Router<Reqs, R>) => Router<Reqs, R2 | Exclude<R, I>>
  <Reqs extends Schema.TaggedRequest.Any, R, I, S, E, R2>(
    self: Router<Reqs, R>,
    tag: Context.Tag<I, S>,
    effect: Effect.Effect<S, E, R2>
  ): Router<Reqs, R2 | Exclude<R, I>>
}

Added in v1.0.0

models

Router (interface)

Signature

export interface Router<Reqs extends Schema.TaggedRequest.Any, R> extends Pipeable {
  readonly [TypeId]: TypeId
  readonly rpcs: ReadonlySet<Rpc.Rpc<Reqs, R>>
}

Added in v1.0.0

Router (namespace)

Added in v1.0.0

Context (type alias)

Signature

export type Context<A extends Router<any, any>> =
  A extends Router<infer Req, infer R> ? R | Serializable.SerializableWithResult.Context<Req> : never

Added in v1.0.0

ContextRaw (type alias)

Signature

export type ContextRaw<A extends Router<any, any>> =
  A extends Router<infer Req, infer R> ? R | Serializable.Serializable.Context<Req> : never

Added in v1.0.0

Request (type alias)

Signature

export type Request<A extends Router<any, any>> = A extends Router<infer Req, infer _R> ? Req : never

Added in v1.0.0

Response (type alias)

Signature

export type Response = [
  index: number,
  response: Schema.ExitEncoded<any, any> | ReadonlyArray<Schema.ExitEncoded<any, any>>
]

Added in v1.0.0

ResponseEffect (type alias)

Signature

export type ResponseEffect = Schema.ExitEncoded<any, any> | ReadonlyArray<Schema.ExitEncoded<any, any>>

Added in v1.0.0

refinements

isRouter

Signature

export declare const isRouter: (u: unknown) => u is Router<any, any>

Added in v1.0.0

type ids

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v1.0.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v1.0.0