Skip to main content Link Search Menu Expand Document (external link)

ExampleServer overview

The exampleServer function generates a Server implementation based on an instance of Api. The listening server will perform all the request and response validations similarly to a real implementation.

Responses returned from the server are generated randomly using the response Schema.

Added in v1.0.0


Table of contents


utils

handle

Create an example implementation for a single endpoint.

Signature

export declare const handle: <
  RemainingEndpoints extends ApiEndpoint.ApiEndpoint.Any,
  Id extends ApiEndpoint.ApiEndpoint.Id<RemainingEndpoints>
>(
  id: Id
) => <R, E>(
  routerBuilder: RouterBuilder.RouterBuilder<R, E, RemainingEndpoints>
) => RouterBuilder.RouterBuilder<
  R | ApiEndpoint.ApiEndpoint.Context<ApiEndpoint.ApiEndpoint.ExtractById<RemainingEndpoints, Id>>,
  E,
  ApiEndpoint.ApiEndpoint.ExcludeById<RemainingEndpoints, Id>
>

Added in v1.0.0

handleRemaining

Create an example implementation for all remaining endpoints.

Signature

export declare const handleRemaining: <RemainingEndpoints extends ApiEndpoint.ApiEndpoint.Any, R, E>(
  routerBuilder: RouterBuilder.RouterBuilder<R, E, RemainingEndpoints>
) => RouterBuilder.RouterBuilder<R | ApiEndpoint.ApiEndpoint.Context<RemainingEndpoints>, E, never>

Added in v1.0.0

make

Generate an example RouterBuilder implementation.

Signature

export declare const make: <A extends Api.Api.Any>(
  api: A
) => RouterBuilder.RouterBuilder<Api.Api.Content<A>, never, never>

Added in v1.0.0