Skip to content

Commit 15a6d89

Browse files
Merge branch 'master' of https://github.com/nestjs/nest
2 parents a3c1bdc + b75460b commit 15a6d89

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export const AXIOS_INSTANCE_TOKEN = 'AXIOS_INSTANCE_TOKEN';
1+
export const AXIOS_INSTANCE_TOKEN = 'AXIOS_INSTANCE_TOKEN';
2+
export const HTTP_MODULE_ID = 'HTTP_MODULE_ID';
Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
import axios, { AxiosRequestConfig } from 'axios';
22
import { Module } from '../decorators/modules/module.decorator';
33
import { DynamicModule } from '../interfaces';
4-
import { AXIOS_INSTANCE_TOKEN } from './http.constants';
4+
import { randomStringGenerator } from '../utils/random-string-generator.util';
5+
import { AXIOS_INSTANCE_TOKEN, HTTP_MODULE_ID } from './http.constants';
56
import { HttpService } from './http.service';
67

78
@Module({
8-
providers: [HttpService, {
9-
provide: AXIOS_INSTANCE_TOKEN,
10-
useValue: axios,
11-
}],
9+
providers: [
10+
HttpService,
11+
{
12+
provide: AXIOS_INSTANCE_TOKEN,
13+
useValue: axios,
14+
},
15+
],
1216
exports: [HttpService],
1317
})
1418
export class HttpModule {
1519
static register(config: AxiosRequestConfig): DynamicModule {
1620
return {
1721
module: HttpModule,
18-
providers: [{
19-
provide: AXIOS_INSTANCE_TOKEN,
20-
useValue: axios.create(config),
21-
}],
22+
providers: [
23+
{
24+
provide: AXIOS_INSTANCE_TOKEN,
25+
useValue: axios.create(config),
26+
},
27+
{
28+
provide: HTTP_MODULE_ID,
29+
useValue: randomStringGenerator(),
30+
},
31+
],
2232
};
2333
}
2434
}

0 commit comments

Comments
 (0)