HttpApiGroup overview
Added in v1.0.0
Table of contents
annotations
annotate
Add an annotation to an HttpApiGroup
.
Signature
export declare const annotate: {
<I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiGroup.Any>(self: A) => A
<A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
}
Added in v1.0.0
annotateEndpoints
For each endpoint in an HttpApiGroup
, add an annotation.
Note that this will only add the annotation to the endpoints before this api is called.
Signature
export declare const annotateEndpoints: {
<I, S>(tag: Context.Tag<I, S>, value: S): <A extends HttpApiGroup.Any>(self: A) => A
<A extends HttpApiGroup.Any, I, S>(self: A, tag: Context.Tag<I, S>, value: S): A
}
Added in v1.0.0
annotateEndpointsMerge
For each endpoint in an HttpApiGroup
, update the annotations with a new context.
Note that this will only update the annotations before this api is called.
Signature
export declare const annotateEndpointsMerge: {
<I>(context: Context.Context<I>): <A extends HttpApiGroup.Any>(self: A) => A
<A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A
}
Added in v1.0.0
annotateMerge
Merge the annotations of an HttpApiGroup
with a new context.
Signature
export declare const annotateMerge: {
<I>(context: Context.Context<I>): <A extends HttpApiGroup.Any>(self: A) => A
<A extends HttpApiGroup.Any, I>(self: A, context: Context.Context<I>): A
}
Added in v1.0.0
constructors
make
An HttpApiGroup
is a collection of HttpApiEndpoint
s. You can use an HttpApiGroup
to represent a portion of your domain.
The endpoints can be implemented later using the HttpApiBuilder.group
api.
Signature
export declare const make: <Name extends string>(identifier: Name) => HttpApiGroup<Name>
Added in v1.0.0
endpoints
add
Add an HttpApiEndpoint
to an HttpApiGroup
.
Signature
export declare const add: {
<A extends HttpApiEndpoint.HttpApiEndpoint.All>(
endpoint: A
): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
) => HttpApiGroup<Name, Endpoints | A, Error, ErrorR>
<
Name extends string,
Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All,
Error,
ErrorR,
A extends HttpApiEndpoint.HttpApiEndpoint.All
>(
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
endpoint: A
): HttpApiGroup<Name, Endpoints | A, Error, ErrorR>
}
Added in v1.0.0
prefix
Add a path prefix to all endpoints in an HttpApiGroup
. Note that this will only add the prefix to the endpoints before this api is called.
Signature
export declare const prefix: {
(
prefix: PathInput
): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
) => HttpApiGroup<Name, Endpoints, Error, ErrorR>
<Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
prefix: PathInput
): HttpApiGroup<Name, Endpoints, Error, ErrorR>
}
Added in v1.0.0
errors
addError
Add an error schema to an HttpApiGroup
, which is shared by all endpoints in the group.
Signature
export declare const addError: {
<A, I, R>(
schema: Schema.Schema<A, I, R>,
annotations?: { readonly status?: number | undefined }
): <Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR>(
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>
) => HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R>
<Name extends string, Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All, Error, ErrorR, A, I, R>(
self: HttpApiGroup<Name, Endpoints, Error, ErrorR>,
schema: Schema.Schema<A, I, R>,
annotations?: { readonly status?: number | undefined }
): HttpApiGroup<Name, Endpoints, Error | A, ErrorR | R>
}
Added in v1.0.0
guards
isHttpApiGroup
Signature
export declare const isHttpApiGroup: (u: unknown) => u is HttpApiGroup.Any
Added in v1.0.0
models
HttpApiGroup (interface)
An HttpApiGroup
is a collection of HttpApiEndpoint
s. You can use an HttpApiGroup
to represent a portion of your domain.
The endpoints can be implemented later using the HttpApiBuilder.group
api.
Signature
export interface HttpApiGroup<
out Name extends string,
out Endpoints extends HttpApiEndpoint.HttpApiEndpoint.All = never,
in out Error = HttpApiDecodeError,
out ErrorR = never
> extends Pipeable {
new (_: never): {}
readonly [TypeId]: TypeId
readonly identifier: Name
readonly endpoints: Chunk.Chunk<Endpoints>
readonly errorSchema: Schema.Schema<Error, unknown, ErrorR>
readonly annotations: Context.Context<never>
}
Added in v1.0.0
HttpApiGroup (namespace)
Added in v1.0.0
Service (interface)
Signature
export interface Service<Name extends string> {
readonly _: unique symbol
readonly name: Name
}
Added in v1.0.0
Any (type alias)
Signature
export type Any =
| HttpApiGroup<any, any, any, any>
| HttpApiGroup<any, any, any, never>
| HttpApiGroup<any, any, never, never>
Added in v1.0.0
Context (type alias)
Signature
export type Context<Group> =
Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _ErrorR>
? _ErrorR | HttpApiEndpoint.HttpApiEndpoint.Context<_Endpoints>
: never
Added in v1.0.0
ContextWithName (type alias)
Signature
export type ContextWithName<Group extends Any, Name extends string> = Context<WithName<Group, Name>>
Added in v1.0.0
Endpoints (type alias)
Signature
export type Endpoints<Group> =
Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _ErrorR> ? _Endpoints : never
Added in v1.0.0
EndpointsWithName (type alias)
Signature
export type EndpointsWithName<Group extends Any, Name extends string> = Endpoints<WithName<Group, Name>>
Added in v1.0.0
Error (type alias)
Signature
export type Error<Group> =
Group extends HttpApiGroup<infer _Name, infer _Endpoints, infer _Error, infer _ErrorR> ? _Error : never
Added in v1.0.0
ErrorWithName (type alias)
Signature
export type ErrorWithName<Group extends Any, Name extends string> = Error<WithName<Group, Name>>
Added in v1.0.0
ToService (type alias)
Signature
export type ToService<Group> =
Group extends HttpApiGroup<infer Name, infer _Endpoints, infer _Error, infer _ErrorR> ? Service<Name> : never
Added in v1.0.0
WithName (type alias)
Signature
export type WithName<Group, Name extends string> = Extract<Group, { readonly identifier: Name }>
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