0
votes

Plugin system for a nestjs app.

I have some kind of service that lives on "core" module. This module is supposed to be a black box, completely sealed. The only way to add new feature is to inject new modules on the system and, eventually, replace some services of the core module.

The problem: Ho do i replace a service at runtime? (@Injectable)

The idea is to replace the old class with a new one with enhanced feature.

1
Why would you change your service at runtime? - Maciej Sikorski
For implementing plugins, adding custom logic to a black box, in a functional style. - Cristian

1 Answers

1
votes
@Module({
providers: [{provide: OldServiceClass, useClass: NewServiceClass}]
})
export class FeatureModule {}