From aadde2d46185a7dbba4c4b2c47c693ff252be219 Mon Sep 17 00:00:00 2001 From: "Marcus S. Abildskov" <8391194+marcus-sa@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:45:24 +0200 Subject: [PATCH] feat(rpc): make controller decorator name or definition optional The rpc controller metadata name would then default to the name of the class Signed-off-by: Marcus S. Abildskov <8391194+marcus-sa@users.noreply.github.com> --- packages/rpc/src/decorators.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/rpc/src/decorators.ts b/packages/rpc/src/decorators.ts index 030968642..9dd63673c 100644 --- a/packages/rpc/src/decorators.ts +++ b/packages/rpc/src/decorators.ts @@ -38,7 +38,7 @@ export class RpcAction { class RpcClass { t = new RpcController; - controller(nameOrDefinition: string | ControllerDefinition) { + controller(nameOrDefinition?: string | ControllerDefinition) { if ('string' === typeof nameOrDefinition) { this.t.name = nameOrDefinition; } else { @@ -49,6 +49,10 @@ class RpcClass { addAction(name: string, action: RpcAction) { this.t.actions.set(name, action); } + + onDecorator(classType: ClassType) { + this.t.name ||= classType.name; + } } export const rpcClass: ClassDecoratorResult = createClassDecoratorContext(RpcClass);