Skip to content

HttpApiGroup

7 exports Added in v1.0.0 Source

Constructors

make

Added in v1.0.0 Source

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

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

Signature

declare function make<Id extends string, TopLevel extends boolean = false>(
  identifier: Id,
  options?: {
    readonly topLevel?: TopLevel;
  },
): HttpApiGroup<Id, never, never, never, TopLevel>;

Guards

Signature

declare function isHttpApiGroup(u: unknown): u is Any;

Models

ApiGroup interface

Added in v1.0.0 Source

Signature

interface ApiGroup<ApiId extends string, Name extends string> {
  readonly _: typeof _;
  readonly apiId: ApiId;
  readonly name: Name;
}

HttpApiGroup

Added in v1.0.0 Source

HttpApiGroup interface

Added in v1.0.0 Source

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

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

Signature

interface HttpApiGroup<
  out Id extends string,
  out Endpoints extends HttpApiEndpoint.HttpApiEndpoint.Any = never,
  in out Error = HttpApiDecodeError,
  out R = never,
  out TopLevel extends true | false = false,
> extends Pipeable {
  constructor(_: never);
  readonly [TypeId]: typeof TypeId;
  readonly annotations: Context<never>;
  readonly endpoints: Record.ReadonlyRecord<string, Endpoints>;
  readonly errorSchema: any;
  readonly identifier: Id;
  readonly middlewares: ReadonlySet<TagClassAny>;
  readonly topLevel: TopLevel;
  add<A extends Any>(endpoint: A): HttpApiGroup<Id, Endpoints | A, Error, R, TopLevel>;
  addError<A, I, RX>(
    schema: any,
    annotations?: {
      readonly status?: number;
    },
  ): HttpApiGroup<Id, Endpoints, Error | A, R | RX, TopLevel>;
  annotate<I, S>(tag: Tag<I, S>, value: S): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
  annotateContext<I>(context: Context<I>): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
  annotateEndpoints<I, S>(
    tag: Tag<I, S>,
    value: S,
  ): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
  annotateEndpointsContext<I>(context: Context<I>): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
  middleware<I extends AnyId, S>(
    middleware: Tag<I, S>,
  ): HttpApiGroup<Id, Endpoints, Error | Error<I>, R | I | ErrorContext<I>, TopLevel>;
  middlewareEndpoints<I extends AnyId, S>(
    middleware: Tag<I, S>,
  ): HttpApiGroup<Id, AddContext<Endpoints, I>, Error, R, TopLevel>;
  prefix(prefix: `/${string}`): HttpApiGroup<Id, Endpoints, Error, R, TopLevel>;
}

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;