Template
1
0

feat: add relay factory

This commit is contained in:
2025-04-25 19:02:22 +00:00
parent 9ff4d2c5fc
commit ee67183a4c
4 changed files with 12 additions and 4 deletions

View File

@@ -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>(),

View File

@@ -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.
*