Skip to content

Commit

Permalink
feat: Add possibility to specify extra providers (#762)
Browse files Browse the repository at this point in the history
* feat: allow consumers to register extra providers

Useful when the consumers wants to use a provider in the `useFactory` method.
Reference: https://stackoverflow.com/a/66164772/10878244

* chore: add the type for the new `extraProviders` param
  • Loading branch information
Gamote authored Apr 26, 2022
1 parent 13963db commit 680c67f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/interfaces/mailer-async-options.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** Dependencies **/
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
import { Provider } from "@nestjs/common";

/** Interfaces **/
import { MailerOptions } from './mailer-options.interface';
Expand All @@ -10,4 +11,5 @@ export interface MailerAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
useClass?: Type<MailerOptionsFactory>;
useExisting?: Type<MailerOptionsFactory>;
useFactory?: (...args: any[]) => Promise<MailerOptions> | MailerOptions;
extraProviders?: Provider[];
}
3 changes: 3 additions & 0 deletions lib/mailer-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export class MailerCoreModule {

/** Services **/
MailerService,

/** Extra providers **/
...(options.extraProviders || []),
],
imports: options.imports,
exports: [
Expand Down

0 comments on commit 680c67f

Please sign in to comment.