feat: add relay factory
This commit is contained in:
@@ -7,7 +7,7 @@ import { Route, RouteMethod } from "./route.ts";
|
||||
|
||||
const SUPPORTED_MEHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
||||
|
||||
export class RelayApi<TRelays extends (Procedure | Route)[]> {
|
||||
export class Api<TRelays extends (Procedure | Route)[]> {
|
||||
readonly #index = {
|
||||
rest: new Map<string, Route>(),
|
||||
rpc: new Map<string, Procedure>(),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Api } from "./api.ts";
|
||||
import { makeRelayClient, RelayClient, RelayClientConfig } from "./client.ts";
|
||||
import { Procedure } from "./procedure.ts";
|
||||
import { Route, RouteMethod } from "./route.ts";
|
||||
@@ -24,6 +25,15 @@ export class Relay<
|
||||
indexRelays(relays, this.#index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new relay api instance with the given relays.
|
||||
*
|
||||
* @param relays - List of relays to handle.
|
||||
*/
|
||||
api<TRelays extends (Procedure | Route)[]>(relays: TRelays): Api<TRelays> {
|
||||
return new Api<TRelays>(relays);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new relay client instance from the instance procedures.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user