title: Implementing strategy in nest.js
body: <p>I am trying to use the strategy pattern for the service, however the Module I try to use as context for strategy seems to only stick to one of the two. Here is the example code:</p>
  <p>animal.module.ts</p>
  <pre><code>@Module({})
  export class AnimalModule {
      static register(strategy): DynamicModule {
          return {
              module: AnimalModule,
              providers: [{ provide: 'STRATEGY', useValue: strategy }, AnimalService],
              imports: [],
              exports: [AnimalService]
          };
      }
  }
  </code></pre>
  <p>animal.service.ts</p>
  <pre><code>@Injectable()
  export class AnimalService {
      constructor (@Inject('STRATEGY') private strategy) {
          this.strategy = strategy
      }
  
      public makeSound() {
          return this.strategy.makeSound()
      }
  }
  </code></pre>
  <p>cat.module.ts</p>
  <pre><code>@Module({
      imports: [
          AnimalModule.register(catStrategy),
      ],
      controllers: [CatController],
      providers: [CatService],
  })
  export class CatModule {}
  </code></pre>
  <p>cat.service.ts</p>
  <pre><code>@Injectable()
  export class CatService {
      constructor(
          private readonly animalService: AnimalService,
      ) {}
  
      public makeSound() {
          return this.animalService.makeSound()
      }
  }
  </code></pre>
  <p>dog.module.ts</p>
  <pre><code>@Module({
      imports: [
          AnimalModule.register(dogStrategy),
      ],
      controllers: [DogController],
      providers: [DogService],
  })
  export class DogModule {}
  </code></pre>
  <p>dog.service.ts</p>
  <pre><code>@Injectable()
  export class DogService {
      constructor(
          private readonly animalService: AnimalService,
      ) {}
  
      public makeSound() {
          return this.animalService.makeSound()
      }
  }
  </code></pre>
  <p>cat.strategy.ts</p>
  <pre><code>class CatStrategy {
      public makeSound() {
          return 'meow';
      }
  }
  
  export const catStrategy = new CatStrategy();
  </code></pre>
  <p>Repo that replicates the issue: <a href="https://github.com/kunukmak/nestjs-strategy-problem-example" rel="nofollow noreferrer">https://github.com/kunukmak/nestjs-strategy-problem-example</a></p>
  <p>To clarify, both catService.makeSound and dogService.makeSound return &quot;meow&quot; in this case. Is it possible to make the dog bark?</p>