forked from xhiroga/nestjs-meetup-online1-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.module.ts
50 lines (49 loc) · 1.56 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
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { APP_FILTER, APP_GUARD } from '@nestjs/core';
import { MongooseModule } from '@nestjs/mongoose';
import { LoggerModule } from 'nestjs-pino';
import { v4 } from 'uuid';
import { AllExceptionsFilter } from './all-exceptions.filter';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AuthGuard } from './auth.guard';
import { CatsModule } from './cats/cats.module';
import { DogsModule } from './dogs/dogs.module';
import { MongooseAsyncProvider } from './mongoose-async.provider';
@Module({
imports: [
ConfigModule.forRoot({
// If environment variables are set, envFile will be ignored.
isGlobal: true,
// If not exists, just ignored.
envFilePath: '.env.local',
}),
LoggerModule.forRootAsync({
useFactory: async () => {
return {
pinoHttp: { level: 'debug', genReqId: () => v4() },
};
}
}),
// MongooseModuleはDynamicModuleで提供される。接続情報の読み込みが必要なため、import時にプロパティや振る舞いを可変にできるDynamicModuleが望ましい。
MongooseModule.forRootAsync({
useClass: MongooseAsyncProvider,
}),
CatsModule,
DogsModule,
],
controllers: [AppController],
providers: [
AppService,
{
provide: APP_FILTER,
useClass: AllExceptionsFilter
},
{
provide: APP_GUARD, useClass: AuthGuard
},
MongooseAsyncProvider
],
})
export class AppModule { }