Skip to content

Commit ada8663

Browse files
feat: add global configuration attribute #1041
1 parent dcbc102 commit ada8663

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/http.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class HttpModule {
2727
static register(config: HttpModuleOptions): DynamicModule {
2828
return {
2929
module: HttpModule,
30+
global: config.global,
3031
providers: [
3132
{
3233
provide: AXIOS_INSTANCE_TOKEN,
@@ -43,6 +44,7 @@ export class HttpModule {
4344
static registerAsync(options: HttpModuleAsyncOptions): DynamicModule {
4445
return {
4546
module: HttpModule,
47+
global: options.global,
4648
imports: options.imports,
4749
providers: [
4850
...this.createAsyncProviders(options),

lib/interfaces/http-module.interface.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import {
66
} from '@nestjs/common';
77
import { AxiosRequestConfig } from 'axios';
88

9-
export type HttpModuleOptions = AxiosRequestConfig;
9+
export type HttpModuleOptions = AxiosRequestConfig & {
10+
/**
11+
* Set to true to register HttpModule as a global module
12+
*/
13+
global?: boolean;
14+
};
1015

1116
export interface HttpModuleOptionsFactory {
1217
createHttpOptions(): Promise<HttpModuleOptions> | HttpModuleOptions;
@@ -20,5 +25,12 @@ export interface HttpModuleAsyncOptions
2025
...args: any[]
2126
) => Promise<HttpModuleOptions> | HttpModuleOptions;
2227
inject?: FactoryProvider['inject'];
28+
/**
29+
* Extra providers to be registered
30+
*/
2331
extraProviders?: Provider[];
32+
/**
33+
* Set to true to register HttpModule as a global module
34+
*/
35+
global?: boolean;
2436
}

0 commit comments

Comments
 (0)