HttpRouter
Combinators
Signature
declare const append: {
<R1, E1>(
route: Route<E1, R1>,
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R | Exclude<R1, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
route: Route<E1, R1>,
): HttpRouter<E | E1, R | Exclude<R1, Provided>>;
};Signature
declare const catchAll: {
<E, E2, R2>(
f: (e: E) => Handler<E2, R2>,
): <R>(self: HttpRouter<E, R>) => HttpRouter<E2, R | Exclude<R2, Provided>>;
<E, R, E2, R2>(
self: HttpRouter<E, R>,
f: (e: E) => Handler<E2, R2>,
): HttpRouter<E2, R | Exclude<R2, Provided>>;
};catchAllCause
Added in v1.0.0
Source
Signature
declare const catchAllCause: {
<E, E2, R2>(
f: (e: Cause<E>) => Handler<E2, R2>,
): <R>(self: HttpRouter<E, R>) => HttpRouter<E2, R | Exclude<R2, Provided>>;
<E, R, E2, R2>(
self: HttpRouter<E, R>,
f: (e: Cause<E>) => Handler<E2, R2>,
): HttpRouter<E2, R | Exclude<R2, Provided>>;
};Signature
declare const catchTag: {
<K extends string, E, E1, R1>(
k: K,
f: (
e: Extract<
E,
{
_tag: K;
}
>,
) => Handler<E1, R1>,
): <R>(self: HttpRouter<E, R>) => HttpRouter<
| E1
| Exclude<
E,
{
_tag: K;
}
>,
R | Exclude<R1, Provided>
>;
<E, R, K extends string, E1, R1>(
self: HttpRouter<E, R>,
k: K,
f: (
e: Extract<
E,
{
_tag: K;
}
>,
) => Handler<E1, R1>,
): HttpRouter<
| E1
| Exclude<
E,
{
_tag: K;
}
>,
R | Exclude<R1, Provided>
>;
};Signature
declare const catchTags: {
<
E,
Cases extends
| {}
| {
[K in string]: (
error: Extract<
E,
{
_tag: K;
}
>,
) => Handler<any, any>;
},
>(
cases: Cases,
): <R>(self: HttpRouter<E, R>) => HttpRouter<
| Exclude<
E,
{
_tag: keyof Cases;
}
>
| {
[K in string | number | symbol]: Cases[K] extends (
...args: Array<any>
) => Effect<any, E, any>
? E
: never;
}[keyof Cases],
| R
| Exclude<
{
[K in string | number | symbol]: Cases[K] extends (
...args: Array<any>
) => Effect<any, any, R>
? R
: never;
}[keyof Cases],
Provided
>
>;
<
R,
E,
Cases extends
| {}
| {
[K in string]: (
error: Extract<
E,
{
_tag: K;
}
>,
) => Handler<any, any>;
},
>(
self: HttpRouter<E, R>,
cases: Cases,
): HttpRouter<
| Exclude<
E,
{
_tag: keyof Cases;
}
>
| {
[K in string | number | symbol]: Cases[K] extends (
...args: Array<any>
) => Effect<any, E, any>
? E
: never;
}[keyof Cases],
| R
| Exclude<
{
[K in string | number | symbol]: Cases[K] extends (
...args: Array<any>
) => Effect<any, any, R>
? R
: never;
}[keyof Cases],
Provided
>
>;
};Signature
declare const concat: {
<R1, E1>(that: HttpRouter<E1, R1>): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R1 | R>;
<E, R, R1, E1>(self: HttpRouter<E, R>, that: HttpRouter<E1, R1>): HttpRouter<E | E1, R | R1>;
};Signature
declare const concatAll: <Routers extends ReadonlyArray<HttpRouter<unknown, unknown>>>(
...routers: Routers
) => [Routers[number]] extends [HttpRouter<infer E, infer R>] ? HttpRouter<E, R> : never;Signature
declare const prefixAll: {
(prefix: PathInput): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E, R>;
<E, R>(self: HttpRouter<E, R>, prefix: PathInput): HttpRouter<E, R>;
};provideService
Added in v1.0.0
Source
Signature
declare const provideService: {
<T extends Tag<any, any>>(
tag: T,
service: Service<T>,
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E, Exclude<R, Identifier<T>>>;
<E, R, T extends Tag<any, any>>(
self: HttpRouter<E, R>,
tag: T,
service: Service<T>,
): HttpRouter<E, Exclude<R, Identifier<T>>>;
};provideServiceEffect
Added in v1.0.0
Source
Signature
declare const provideServiceEffect: {
<T extends Tag<any, any>, R1, E1>(
tag: T,
effect: Effect<Service<T>, E1, R1>,
): <E, R>(
self: HttpRouter<E, R>,
) => HttpRouter<
E1 | E,
Exclude<R, Identifier<T>> | Exclude<Exclude<R1, Provided>, Identifier<T>>
>;
<E, R, T extends Tag<any, any>, R1, E1>(
self: HttpRouter<E, R>,
tag: T,
effect: Effect<Service<T>, E1, R1>,
): HttpRouter<E | E1, Exclude<R, Identifier<T>> | Exclude<Exclude<R1, Provided>, Identifier<T>>>;
};Signature
declare const transform: {
<E, R, R1, E1>(
f: (self: Handler<E, R>) => HttpApp<Respondable, E1, R1>,
): (self: HttpRouter<E, R>) => HttpRouter<E1, Exclude<R1, Provided>>;
<E, R, R1, E1>(
self: HttpRouter<E, R>,
f: (self: Handler<E, R>) => HttpApp<Respondable, E1, R1>,
): HttpRouter<E1, Exclude<R1, Provided>>;
};Signature
declare const use: {
<E, R, R1, E1>(
f: (self: Middleware<E, R>) => Default<E1, R1>,
): (self: HttpRouter<E, R>) => HttpRouter<E1, Exclude<R1, Provided>>;
<E, R, R1, E1>(
self: HttpRouter<E, R>,
f: (self: Middleware<E, R>) => Default<E1, R1>,
): HttpRouter<E1, Exclude<R1, Provided>>;
};Constructors
Signature
declare const empty: HttpRouter;fromIterable
Added in v1.0.0
Source
Signature
declare const fromIterable: <R extends Route<any, any>>(
routes: Iterable<R>,
) => HttpRouter<
R extends Route<infer E, infer _> ? E : never,
R extends Route<infer _, infer Env> ? Env : never
>;Signature
declare const makeRoute: <E, R>(
method: Method.HttpMethod | "*",
path: PathInput,
handler: Route.Handler<E, R>,
options?: {
readonly prefix?: string;
readonly uninterruptible?: boolean;
},
) => Route<E, HttpRouter.ExcludeProvided<R>>;Models
HttpRouter interface
Added in v1.0.0
Source
Signature
interface HttpRouter<E = never, R = never>
extends Default<E | Error.RouteNotFound, Exclude<R, RouteContext>>, Inspectable {
readonly [TypeId]: typeof TypeId;
readonly mounts: Chunk<
readonly [
string,
Default<E, R>,
(
| {
readonly includePrefix?: boolean;
}
| undefined
),
]
>;
readonly routes: Chunk<Route<E, R>>;
}Signature
type PathInput = `/${string}` | "*";Signature
interface Route<E = never, R = never> extends Inspectable {
readonly [RouteTypeId]: typeof RouteTypeId;
readonly handler: Handler<E, R>;
readonly method: HttpMethod | "*";
readonly path: PathInput;
readonly prefix: Option<string>;
readonly uninterruptible: boolean;
}RouteContext interface
Added in v1.0.0
Source
Signature
interface RouteContext {
readonly [RouteContextTypeId]: typeof RouteContextTypeId;
readonly params: Readonly<Record<string, string | undefined>>;
readonly route: Route<unknown, unknown>;
}Other
HttpRouter
Added in v1.0.0
Source
Route Context
Signature
declare const params: Effect.Effect<
Readonly<Record<string, string | undefined>>,
never,
RouteContext
>;RouteContext
Added in v1.0.0
Source
Signature
declare const RouteContext: Tag<RouteContext, RouteContext>;schemaJson
Added in v1.0.0
Source
Signature
declare const schemaJson: <
R,
I extends Partial<{
readonly body: any;
readonly cookies: Readonly<Record<string, string | undefined>>;
readonly headers: Readonly<Record<string, string | undefined>>;
readonly method: Method.HttpMethod;
readonly pathParams: Readonly<Record<string, string | undefined>>;
readonly searchParams: Readonly<Record<string, string | ReadonlyArray<string> | undefined>>;
readonly url: string;
}>,
A,
>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions,
) => Effect.Effect<
A,
Error.RequestError | ParseResult.ParseError,
RouteContext | R | ServerRequest.HttpServerRequest | ServerRequest.ParsedSearchParams
>;schemaNoBody
Added in v1.0.0
Source
Signature
declare const schemaNoBody: <
R,
I extends Partial<{
readonly cookies: Readonly<Record<string, string | undefined>>;
readonly headers: Readonly<Record<string, string | undefined>>;
readonly method: Method.HttpMethod;
readonly pathParams: Readonly<Record<string, string | undefined>>;
readonly searchParams: Readonly<Record<string, string | ReadonlyArray<string> | undefined>>;
readonly url: string;
}>,
A,
>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions,
) => Effect.Effect<
A,
ParseResult.ParseError,
R | RouteContext | ServerRequest.HttpServerRequest | ServerRequest.ParsedSearchParams
>;schemaParams
Added in v1.0.0
Source
Signature
declare const schemaParams: <
A,
I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>,
R,
>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions,
) => Effect.Effect<A, ParseResult.ParseError, R | RouteContext | ServerRequest.ParsedSearchParams>;schemaPathParams
Added in v1.0.0
Source
Signature
declare const schemaPathParams: <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions,
) => Effect.Effect<A, ParseResult.ParseError, R | RouteContext>;Router Config
currentRouterConfig
Added in v1.0.0
Source
Signature
declare const currentRouterConfig: FiberRef<Partial<RouterConfig>>;setRouterConfig
Added in v1.0.0
Source
Signature
declare const setRouterConfig: (config: Partial<RouterConfig>) => Layer.Layer<never>;withRouterConfig
Added in v1.0.0
Source
Signature
declare const withRouterConfig: {
(config: RouterConfig): <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, R>;
<A, E, R>(effect: Effect<A, E, R>, config: RouterConfig): Effect<A, E, R>;
};Routing
Signature
declare const all: {
<R1, E1>(
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R | Exclude<R1, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): HttpRouter<E | E1, R | Exclude<R1, Provided>>;
};Signature
declare const del: {
<R1, E1>(
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R | Exclude<R1, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): HttpRouter<E | E1, R | Exclude<R1, Provided>>;
};Signature
declare const get: {
<R1, E1>(
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R | Exclude<R1, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): HttpRouter<E | E1, R | Exclude<R1, Provided>>;
};Signature
declare const head: {
<R1, E1>(
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R | Exclude<R1, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): HttpRouter<E | E1, R | Exclude<R1, Provided>>;
};Signature
declare const mount: {
<R1, E1>(
path: `/${string}`,
that: HttpRouter<E1, R1>,
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R1 | R>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: `/${string}`,
that: HttpRouter<E1, R1>,
): HttpRouter<E | E1, R | R1>;
};Signature
declare const mountApp: {
<R1, E1>(
path: `/${string}`,
that: Default<E1, R1>,
options?: {
readonly includePrefix?: boolean;
},
): <E, R>(
self: HttpRouter<E, R>,
) => HttpRouter<E1 | E, Exclude<R1, Provided> | Exclude<R, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: `/${string}`,
that: Default<E1, R1>,
options?: {
readonly includePrefix?: boolean;
},
): HttpRouter<E | E1, Exclude<R, Provided> | Exclude<R1, Provided>>;
};Signature
declare const options: {
<R1, E1>(
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R | Exclude<R1, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): HttpRouter<E | E1, R | Exclude<R1, Provided>>;
};Signature
declare const patch: {
<R1, E1>(
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R | Exclude<R1, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): HttpRouter<E | E1, R | Exclude<R1, Provided>>;
};Signature
declare const post: {
<R1, E1>(
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R | Exclude<R1, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): HttpRouter<E | E1, R | Exclude<R1, Provided>>;
};Signature
declare const put: {
<R1, E1>(
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): <E, R>(self: HttpRouter<E, R>) => HttpRouter<E1 | E, R | Exclude<R1, Provided>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): HttpRouter<E | E1, R | Exclude<R1, Provided>>;
};Signature
declare const route: (method: Method.HttpMethod | "*") => {
<R1, E1>(
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): <E, R>(
self: HttpRouter<E, R>,
) => HttpRouter<E1 | E, R | Exclude<R1, Scope | HttpServerRequest | RouteContext>>;
<E, R, E1, R1>(
self: HttpRouter<E, R>,
path: PathInput,
handler: Handler<E1, R1>,
options?: {
readonly uninterruptible?: boolean;
},
): HttpRouter<E | E1, R | Exclude<R1, Scope | HttpServerRequest | RouteContext>>;
};Type Ids
RouteContextTypeId
Added in v1.0.0
Source
Signature
declare const RouteContextTypeId: unique symbol;RouteContextTypeId type
Added in v1.0.0
Source
Signature
type RouteContextTypeId = typeof RouteContextTypeId;RouteTypeId
Added in v1.0.0
Source
Signature
declare const RouteTypeId: unique symbol;RouteTypeId type
Added in v1.0.0
Source
Signature
type RouteTypeId = typeof RouteTypeId;Signature
declare const TypeId: unique symbol;Signature
type TypeId = typeof TypeId;Utils
prefixPath
Added in v1.0.0
Source
Signature
declare const prefixPath: {
(prefix: string): (self: string) => string;
(self: string, prefix: string): string;
};Signature
declare const toHttpApp: <E, R>(
self: HttpRouter<E, R>,
) => Effect.Effect<App.Default<E | Error.RouteNotFound, R>>;