Skip to content

Commit

Permalink
feat: add global option
Browse files Browse the repository at this point in the history
  • Loading branch information
liaoliaots committed Feb 19, 2022
1 parent 3849b48 commit 617d204
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
8 changes: 4 additions & 4 deletions lib/cluster/cluster.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ClusterModule implements OnApplicationShutdown {
/**
* Registers the module synchronously.
*/
static forRoot(options: ClusterModuleOptions): DynamicModule {
static forRoot(options: ClusterModuleOptions, isGlobal = true): DynamicModule {
const clusterClientProviders = createClusterClientProviders();
const providers: Provider[] = [
createOptionsProvider(options),
Expand All @@ -34,7 +34,7 @@ export class ClusterModule implements OnApplicationShutdown {
];

return {
global: true,
global: isGlobal,
module: ClusterModule,
providers,
exports: [ClusterManager, ...clusterClientProviders]
Expand All @@ -44,7 +44,7 @@ export class ClusterModule implements OnApplicationShutdown {
/**
* Registers the module asynchronously.
*/
static forRootAsync(options: ClusterModuleAsyncOptions): DynamicModule {
static forRootAsync(options: ClusterModuleAsyncOptions, isGlobal = true): DynamicModule {
if (!options.useFactory && !options.useClass && !options.useExisting) {
throw new RedisError(MISSING_CONFIGURATION);
}
Expand All @@ -59,7 +59,7 @@ export class ClusterModule implements OnApplicationShutdown {
];

return {
global: true,
global: isGlobal,
module: ClusterModule,
imports: options.imports,
providers,
Expand Down
8 changes: 4 additions & 4 deletions lib/redis/redis.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class RedisModule implements OnApplicationShutdown {
/**
* Registers the module synchronously.
*/
static forRoot(options: RedisModuleOptions = {}): DynamicModule {
static forRoot(options: RedisModuleOptions = {}, isGlobal = true): DynamicModule {
const redisClientProviders = createRedisClientProviders();
const providers: Provider[] = [
createOptionsProvider(options),
Expand All @@ -34,7 +34,7 @@ export class RedisModule implements OnApplicationShutdown {
];

return {
global: true,
global: isGlobal,
module: RedisModule,
providers,
exports: [RedisManager, ...redisClientProviders]
Expand All @@ -44,7 +44,7 @@ export class RedisModule implements OnApplicationShutdown {
/**
* Registers the module asynchronously.
*/
static forRootAsync(options: RedisModuleAsyncOptions): DynamicModule {
static forRootAsync(options: RedisModuleAsyncOptions, isGlobal = true): DynamicModule {
if (!options.useFactory && !options.useClass && !options.useExisting) {
throw new RedisError(MISSING_CONFIGURATION);
}
Expand All @@ -59,7 +59,7 @@ export class RedisModule implements OnApplicationShutdown {
];

return {
global: true,
global: isGlobal,
module: RedisModule,
imports: options.imports,
providers,
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@
"@/(.*)": [
"<rootDir>/$1"
]
},
"coverageReporters": [
"json-summary"
]
}
},
"commitlint": {
"extends": [
Expand Down

0 comments on commit 617d204

Please sign in to comment.