HttpApi overview
Added in v1.0.0
Table of contents
annotations
annotate
Signature
export declare const annotate: {
<I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApi.Any>(self: A) => A
<A extends HttpApi.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
}
Added in v1.0.0
annotateMerge
Signature
export declare const annotateMerge: {
<I>(context: Context.Context<I>): <A extends HttpApi.Any>(self: A) => A
<A extends HttpApi.Any, I>(self: A, context: Context.Context<I>): A
}
Added in v1.0.0
constructors
addGroup
Add a HttpApiGroup
to an HttpApi
.
Signature
export declare const addGroup: {
<Group extends HttpApiGroup.HttpApiGroup.Any>(
group: Group
): <Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR>(
self: HttpApi<Groups, Error, ErrorR>
) => HttpApi<Groups | Group, Error, ErrorR>
<Group extends HttpApiGroup.HttpApiGroup.Any>(
path: HttpRouter.PathInput,
group: Group
): <Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR>(
self: HttpApi<Groups, Error, ErrorR>
) => HttpApi<Groups | Group, Error, ErrorR>
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, Group extends HttpApiGroup.HttpApiGroup.Any>(
self: HttpApi<Groups, Error, ErrorR>,
group: Group
): HttpApi<Groups | Group, Error, ErrorR>
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, Group extends HttpApiGroup.HttpApiGroup.Any>(
self: HttpApi<Groups, Error, ErrorR>,
path: HttpRouter.PathInput,
group: Group
): HttpApi<Groups | Group, Error, ErrorR>
}
Added in v1.0.0
empty
An empty HttpApi
. You can use this to start building your HttpApi
.
You can add groups to this HttpApi
using the addGroup
function.
Signature
export declare const empty: HttpApi<never, never, never>
Added in v1.0.0
errors
addError
Add an error schema to an HttpApi
, which is shared by all endpoints in the HttpApi
.
Useful for adding error types from middleware or other shared error types.
Signature
export declare const addError: {
<A, I, R>(
schema: Schema.Schema<A, I, R>,
annotations?: { readonly status?: number | undefined }
): <Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR>(
self: HttpApi<Groups, Error, ErrorR>
) => HttpApi<Groups, Error | A, ErrorR | R>
<Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR, A, I, R>(
self: HttpApi<Groups, Error, ErrorR>,
schema: Schema.Schema<A, I, R>,
annotations?: { readonly status?: number | undefined }
): HttpApi<Groups, Error | A, ErrorR | R>
}
Added in v1.0.0
guards
isHttpApi
Signature
export declare const isHttpApi: (u: unknown) => u is HttpApi<any, any>
Added in v1.0.0
models
HttpApi (interface)
An HttpApi
represents a collection of HttpApiGroup
s. You can use an HttpApi
to represent your entire domain.
Signature
export interface HttpApi<
out Groups extends HttpApiGroup.HttpApiGroup.Any = never,
in out Error = never,
out ErrorR = never
> extends Pipeable {
new (_: never): {}
readonly [TypeId]: TypeId
readonly groups: Chunk.Chunk<Groups>
readonly errorSchema: Schema.Schema<Error, unknown, ErrorR>
readonly annotations: Context.Context<never>
}
Added in v1.0.0
HttpApi (namespace)
Added in v1.0.0
Any (interface)
Signature
export interface Any extends Pipeable {
new (_: never): {}
readonly [TypeId]: TypeId
readonly groups: Chunk.Chunk<HttpApiGroup.HttpApiGroup.Any>
readonly errorSchema: Schema.Schema.All
readonly annotations: Context.Context<never>
}
Added in v1.0.0
Service (interface)
Signature
export interface Service {
readonly _: unique symbol
}
Added in v1.0.0
Context (type alias)
Signature
export type Context<A> =
A extends HttpApi<infer _Groups, infer _ApiError, infer _ApiErrorR>
? _ApiErrorR | HttpApiGroup.HttpApiGroup.Context<_Groups>
: never
Added in v1.0.0
reflection
reflect
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
export declare const reflect: <Groups extends HttpApiGroup.HttpApiGroup.Any, Error, ErrorR>(
self: HttpApi<Groups, Error, ErrorR>,
options: {
readonly onGroup: (options: {
readonly group: HttpApiGroup.HttpApiGroup<string, any>
readonly mergedAnnotations: Context.Context<never>
}) => void
readonly onEndpoint: (options: {
readonly group: HttpApiGroup.HttpApiGroup<string, any>
readonly endpoint: HttpApiEndpoint.HttpApiEndpoint<string, HttpMethod>
readonly mergedAnnotations: Context.Context<never>
readonly successAST: Option.Option<AST.AST>
readonly successStatus: number
readonly successEncoding: HttpApiSchema.Encoding
readonly errors: ReadonlyMap<number, Option.Option<AST.AST>>
}) => void
}
) => void
Added in v1.0.0
tags
HttpApi
Signature
export declare const HttpApi: Context.Tag<HttpApi.Service, HttpApi.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