Skip to content
Effect Days 2026 Get your ticket

HttpApi

9 exports Added in v1.0.0 Source

Constructors

make

Added in v1.0.0 Source

An HttpApi is a collection of HttpApiEndpoints. You can use an HttpApi to represent a portion of your domain.

The endpoints can be implemented later using the HttpApiBuilder.make api.

Signature

declare function make<Id extends string>(identifier: Id): HttpApi<Id, never, HttpApiDecodeError>

Guards

isHttpApi

Added in v1.0.0 Source

Signature

declare function isHttpApi(u: unknown): u is Any

Models

HttpApi

Added in v1.0.0 Source

HttpApi interface

Added in v1.0.0 Source

An HttpApi is a collection of HttpApiEndpoints. You can use an HttpApi to represent a portion of your domain.

The endpoints can be implemented later using the HttpApiBuilder.make api.

Signature

interface HttpApi<out Id extends string, out Groups extends HttpApiGroup.HttpApiGroup.Any = never, in out E = never, out R = never> extends Pipeable {
constructor(_: never);
readonly [TypeId]: typeof TypeId;
readonly annotations: Context<never>;
readonly errorSchema: any;
readonly groups: Record.ReadonlyRecord<string, Groups>;
readonly identifier: Id;
readonly middlewares: ReadonlySet<TagClassAny>;
add<A extends Any>(group: A): HttpApi<Id, Groups | A, E, R>;
addError<A, I, RX>(schema: any, annotations?: {
readonly status?: number;
}): HttpApi<Id, Groups, E | A, R | RX>;
addHttpApi<Id2 extends string, Groups2 extends Any, E2, R2>(api: HttpApi<Id2, Groups2, E2, R2>): HttpApi<Id, Groups | AddContext<Groups2, R2>, E | E2, R>;
annotate<I, S>(tag: Tag<I, S>, value: S): HttpApi<Id, Groups, E, R>;
annotateContext<I>(context: Context<I>): HttpApi<Id, Groups, E, R>;
middleware<I extends AnyId, S>(middleware: Tag<I, S>): HttpApi<Id, Groups, E | Error<I>, R | I | ErrorContext<I>>;
prefix(prefix: `/${string}`): HttpApi<Id, Groups, E, R>;
}

Reflection

reflect

Added in v1.0.0 Source

Extract metadata from an HttpApi, which can be used to generate documentation or other tooling.

See the OpenApi & HttpApiClient modules for examples of how to use this function.

Signature

declare function reflect<Id extends string, Groups extends Any, Error, R>(self: HttpApi<Id, Groups, Error, R>, options: {
readonly onEndpoint: (options: {
readonly endpoint: HttpApiEndpoint<string, HttpMethod>;
readonly errors: ReadonlyMap<number, {
readonly ast: Option<AST>;
readonly description: Option<string>;
}>;
readonly group: AnyWithProps;
readonly mergedAnnotations: Context<never>;
readonly middleware: ReadonlySet<TagClassAny>;
readonly payloads: ReadonlyMap<string, {
readonly ast: AST;
readonly encoding: Encoding;
}>;
readonly successes: ReadonlyMap<number, {
readonly ast: Option<AST>;
readonly description: Option<string>;
}>;
}) => void;
readonly onGroup: (options: {
readonly group: AnyWithProps;
readonly mergedAnnotations: Context<never>;
}) => void;
readonly predicate?: Predicate<{
readonly endpoint: AnyWithProps;
readonly group: AnyWithProps;
}>;
}): void

Tags

Adds additional schemas to components/schemas. The provided schemas must have a identifier annotation.

Signature

declare class AdditionalSchemas extends any {
constructor();
}

Api

Added in v1.0.0 Source

Signature

declare class Api extends any {
constructor();
}

Type Ids

TypeId

Added in v1.0.0 Source

Signature

declare const TypeId: unique symbol

TypeId type

Added in v1.0.0 Source

Signature

type TypeId = typeof TypeId