I am working with a NestJs monorepo that contains several Apps (microservices) and Libs. One common Service class is used across all apps, so I decided to extract it into a separate lib.
Initially, I thought this was a good idea. However, I soon realized that I have a decorator on a method within this class that requires a unique const string for each individual app.
It seems challenging to accomplish this. Is there a solution available?
Essentially, I need a way to "inject" a const string from the loading app into the lib so that it can be used by the decorator.
Specifically, the decorator in question is the @RabbitSubscribe()
decorator from golevelup/nestjs-rabbitmq
. The queue name (a const string parameter for the decorator) needs to vary for each module.
More broadly, if I have this class in a lib:
@Injectable()
export class MyService {
@ADecorator({
param: 'this is the string',
})
myFunction() { ... }
}
How can I import it into different Apps with a different string parameter for each app?