Skip to content

Commit

Permalink
feat(rpc): make controller decorator name or definition optional
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
marcus-sa authored Oct 21, 2023
1 parent dd08c77 commit aadde2d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/rpc/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class RpcAction {
class RpcClass {
t = new RpcController;

controller(nameOrDefinition: string | ControllerDefinition<any>) {
controller(nameOrDefinition?: string | ControllerDefinition<any>) {
if ('string' === typeof nameOrDefinition) {
this.t.name = nameOrDefinition;
} else {
Expand All @@ -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<typeof RpcClass> = createClassDecoratorContext(RpcClass);
Expand Down

0 comments on commit aadde2d

Please # to comment.