Type alias Api<Closure, Meta>

Api<Closure, Meta>: { [key: string]: Api<Closure, Meta> | Endpoint<any, any, Closure, Meta> }

An Api type is effecitvely just an arbitrarily nested set of endpoints allowing for nice organization of the interface over which estuary-rpc operates. To start using estuary-rpc, you may first define your own ExampleApi type extending from this Api interface, and then define an exampleApiMetaDefition of type ExampleApi<unknown, CustomMeta> (without a closure as the MetaDefinition is not used as a function). Alternatively, you may just define your exampleApiMetaDefinition and use type inference and ApiTypeOf to deduce your API type from that. That is, you may either explicitly or implicitly extend this Api. From there, on the clientside a call to createApiClient will create an ExampleApi<FetchOpts, Meta>, while on the serverside a call to createApiServer will create an ExampleApi<ApiContext, Meta>.

Example

export interface ExampleApi<Closure, Meta> extends Api<Closure, Meta> {
foo: FooService<Closure, Meta>;
fileUpload: Endpoint<void, void, Closure, Meta>;
}

export interface FooService<Closure, Meta> extends Api<Closure, Meta> {
simpleGet: Endpoint<number, number, Closure, Meta>;
simpleStream: StreamEndpoint<string, boolean, Closure, Meta>;
}

Type Parameters

Type declaration

  • [key: string]: Api<Closure, Meta> | Endpoint<any, any, Closure, Meta>

Generated using TypeDoc