From c44b6bca8c37b5056f9f4c372634e63bf18a7639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Villard?= Date: Mon, 4 Apr 2022 15:41:44 +0200 Subject: [PATCH] feat: allow adding extraProviders when the module is loaded asynchronously --- lib/interfaces/typeorm-options.interface.ts | 3 ++- lib/typeorm-core.module.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/interfaces/typeorm-options.interface.ts b/lib/interfaces/typeorm-options.interface.ts index 1082239a5..c9b96b47d 100644 --- a/lib/interfaces/typeorm-options.interface.ts +++ b/lib/interfaces/typeorm-options.interface.ts @@ -1,4 +1,4 @@ -import { ModuleMetadata, Type } from '@nestjs/common'; +import {ModuleMetadata, Provider, Type} from '@nestjs/common'; import { Connection, ConnectionOptions } from 'typeorm'; export type TypeOrmModuleOptions = { @@ -54,4 +54,5 @@ export interface TypeOrmModuleAsyncOptions ) => Promise | TypeOrmModuleOptions; connectionFactory?: TypeOrmConnectionFactory; inject?: any[]; + extraProviders?: Provider[]; } diff --git a/lib/typeorm-core.module.ts b/lib/typeorm-core.module.ts index 3f512a645..26c14f823 100644 --- a/lib/typeorm-core.module.ts +++ b/lib/typeorm-core.module.ts @@ -104,6 +104,7 @@ export class TypeOrmCoreModule implements OnApplicationShutdown { provide: TYPEORM_MODULE_ID, useValue: generateString(), }, + ...(options.extraProviders || []), ], exports: [entityManagerProvider, connectionProvider], };