Skip to content

Commit

Permalink
feat: add extra providers on module factory method
Browse files Browse the repository at this point in the history
  • Loading branch information
guilopesn committed Aug 31, 2023
1 parent 7d9bc72 commit 0073a07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/interfaces/jwt-module-options.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModuleMetadata, Type } from '@nestjs/common';
import { ModuleMetadata, Provider, Type } from '@nestjs/common';
import * as jwt from 'jsonwebtoken';

export enum JwtSecretRequestType {
Expand Down Expand Up @@ -34,6 +34,7 @@ export interface JwtModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
useClass?: Type<JwtOptionsFactory>;
useFactory?: (...args: any[]) => Promise<JwtModuleOptions> | JwtModuleOptions;
inject?: any[];
extraProviders?: Provider[];
}

export interface JwtSignOptions extends jwt.SignOptions {
Expand Down
5 changes: 4 additions & 1 deletion lib/jwt.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export class JwtModule {
module: JwtModule,
global: options.global,
imports: options.imports || [],
providers: this.createAsyncProviders(options)
providers: [
...this.createAsyncProviders(options),
...(options.extraProviders ?? [])
]
};
}

Expand Down

0 comments on commit 0073a07

Please sign in to comment.