HttpApi
Constructors
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
Models
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
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