feat: minor cleanup and doc update
This commit is contained in:
@@ -23,9 +23,11 @@ export class Procedure<TState extends State = State> {
|
||||
* ```ts
|
||||
* relay
|
||||
* .method("user:create")
|
||||
* .params({
|
||||
* bar: z.number()
|
||||
* })
|
||||
* .params(
|
||||
* z.object({
|
||||
* bar: z.number()
|
||||
* })
|
||||
* )
|
||||
* .handle(async ({ bar }) => {
|
||||
* console.log(typeof bar); // => number
|
||||
* });
|
||||
@@ -46,7 +48,7 @@ export class Procedure<TState extends State = State> {
|
||||
* ```ts
|
||||
* const hasFooBar = action
|
||||
* .make("hasFooBar")
|
||||
* .response(z.object({ foobar: z.number() }))
|
||||
* .output(z.object({ foobar: z.number() }))
|
||||
* .handle(async () => {
|
||||
* return {
|
||||
* foobar: 1,
|
||||
|
||||
@@ -16,15 +16,6 @@ export class Relay<TProcedures extends Procedures, TProcedureIndex = ProcedureIn
|
||||
indexProcedures(procedures, this.#index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a registered procedure registered with the relay instance.
|
||||
*
|
||||
* @param method - Method name assigned to the procedure.
|
||||
*/
|
||||
procedure<TMethod extends keyof TProcedureIndex>(method: TMethod): TProcedureIndex[TMethod] {
|
||||
return this.#index.get(method) as TProcedureIndex[TMethod];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new relay client instance from the instance procedures.
|
||||
*
|
||||
@@ -33,6 +24,15 @@ export class Relay<TProcedures extends Procedures, TProcedureIndex = ProcedureIn
|
||||
client(config: RelayClientConfig): this["$inferClient"] {
|
||||
return makeRelayClient(config, this.procedures) as any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a registered procedure registered with the relay instance.
|
||||
*
|
||||
* @param method - Method name assigned to the procedure.
|
||||
*/
|
||||
method<TMethod extends keyof TProcedureIndex>(method: TMethod): TProcedureIndex[TMethod] {
|
||||
return this.#index.get(method) as TProcedureIndex[TMethod];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user