Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add extra providers on module factory method #1426

Merged
merged 1 commit into from Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/interfaces/jwt-module-options.interface.ts
@@ -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
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