forked from NarHakobyan/awesome-nest-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.module.ts
54 lines (51 loc) · 1.62 KB
/
app.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import './boilerplate.polyfill';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { APP_FILTER } from '@nestjs/core';
import { TypeOrmModule } from '@nestjs/typeorm';
import { I18nJsonParser, I18nModule } from 'nestjs-i18n';
import path from 'path';
import { AllExceptionsFilter } from './filters/all-exceptions.filter';
import { AuthModule } from './modules/auth/auth.module';
import { HealthCheckerModule } from './modules/health-checker/health-checker.module';
import { PostModule } from './modules/post/post.module';
import { UserModule } from './modules/user/user.module';
import { ApiConfigService } from './shared/services/api-config.service';
import { SharedModule } from './shared/shared.module';
@Module({
imports: [
AuthModule,
UserModule,
PostModule,
ConfigModule.forRoot({
isGlobal: true,
envFilePath: '.env',
}),
TypeOrmModule.forRootAsync({
imports: [SharedModule],
useFactory: (configService: ApiConfigService) =>
configService.postgresConfig,
inject: [ApiConfigService],
}),
I18nModule.forRootAsync({
useFactory: (configService: ApiConfigService) => ({
fallbackLanguage: configService.fallbackLanguage,
parserOptions: {
path: path.join(__dirname, '/i18n/'),
watch: configService.isDevelopment,
},
}),
imports: [SharedModule],
parser: I18nJsonParser,
inject: [ApiConfigService],
}),
HealthCheckerModule,
],
providers: [
{
provide: APP_FILTER,
useClass: AllExceptionsFilter,
},
],
})
export class AppModule {}