-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.module.ts
executable file
·67 lines (65 loc) · 1.71 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
55
56
57
58
59
60
61
62
63
64
65
66
67
import { Module, ValidationPipe } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { APP_FILTER, APP_PIPE } from '@nestjs/core';
import { ServeStaticModule } from '@nestjs/serve-static';
import { LoggerModule } from 'nestjs-pino';
import { PrismaModule } from 'nestjs-prisma';
import { AuthModule } from './auth/auth.module';
import { ExceptionsFilter } from './common';
import { CommonModule } from './common/common.module';
import { configuration, loggerOptions } from './config';
import { SampleModule } from './sample/sample.module';
@Module({
imports: [
// https://github.com/iamolegga/nestjs-pino
LoggerModule.forRoot(loggerOptions),
// Configuration
ConfigModule.forRoot({
isGlobal: true,
load: [configuration],
}),
// Static
ServeStaticModule.forRoot({
rootPath: `${__dirname}/../public`,
}),
/**
* https://docs.nestjs.com/recipes/prisma
* https://www.prisma.io/nestjs
* https://nestjs-prisma.dev
*/
PrismaModule.forRootAsync({
isGlobal: true,
useFactory: (config: ConfigService) => ({
prismaOptions: {
...config.get('prismaOptions'),
datasources: {
db: {
url: config.getOrThrow('DATABASE_URL'),
},
},
},
}),
inject: [ConfigService],
}),
// Global
CommonModule,
// Authentication
AuthModule,
// API Sample
SampleModule,
],
providers: [
{
provide: APP_FILTER,
useClass: ExceptionsFilter,
},
{
provide: APP_PIPE,
useValue: new ValidationPipe({
transform: true,
whitelist: true,
}),
},
],
})
export class AppModule {}