hey all,
having issues setting up the following decorator, I did not like the idea of setting up a customer decorator and declaring service globally in order to access their functionalities. So I opted for something this.
@Injectable()
export class SendFCMNotificationService {
constructor(private readonly someService: SomeService) {}
static decoratorFn() {
return createParamDecorator(async (data: any, ctx: ExecutionContext) => {
const result = await ctx.switchToHttp().getResponse().send();
// Wait for the controller function to finish before sending the notification
await result;
});
}
}
which is then imported on a route level like so
@HttpCode(HttpStatus.OK)
@Get('test')
@SendFCMNotificationService.decoratorFn()
findJob() {
return '1';
}
the issue is I keep getting the following error, the error does not really care for the return type of the controller function, it just keep throwing the same error witch the TypedPropertyDescriptor being string, number, object, any, etc.
Decorator function return type 'ParameterDecorator' is not assignable to type 'void | TypedPropertyDescriptor<() => string>'
Not sure what is causing this, I've been at it for quite a while, any help would be much appreciated!