fennec-be/src/app.module.ts

49 lines
1.7 KiB
TypeScript
Raw Normal View History

2021-01-31 11:15:21 +08:00
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { GraphQLModule } from '@nestjs/graphql';
import { TypeOrmModule } from '@nestjs/typeorm';
2021-01-31 11:15:21 +08:00
import { AppController } from './app.controller';
import { AppResolver } from './app.resolver';
2021-01-31 11:15:21 +08:00
import { AppService } from './app.service';
2021-01-31 19:42:17 +08:00
import { ProjectsModule } from './projects/projects.module';
import { ReposModule } from './repos/repos.module';
import { PipelinesModule } from './pipelines/pipelines.module';
import configuration from './commons/config/configuration';
2021-01-31 11:15:21 +08:00
@Module({
imports: [
ConfigModule.forRoot({
load: [configuration],
}),
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
type: 'postgres',
host: configService.get<string>('db.postgres.host'),
port: configService.get<number>('db.postgres.port'),
username: configService.get<string>('db.postgres.username'),
password: configService.get<string>('db.postgres.password'),
database: configService.get<string>('db.postgres.database'),
synchronize: true,
autoLoadEntities: true,
}),
inject: [ConfigService],
}),
GraphQLModule.forRootAsync({
imports: [ConfigModule],
2021-02-24 11:15:36 +08:00
useFactory: (configService: ConfigService) => ({
debug: configService.get<string>('env') !== 'prod',
playground: true,
autoSchemaFile: true,
}),
inject: [ConfigService],
}),
2021-01-31 19:42:17 +08:00
ProjectsModule,
ReposModule,
PipelinesModule,
],
2021-01-31 11:15:21 +08:00
controllers: [AppController],
providers: [AppService, AppResolver],
2021-01-31 11:15:21 +08:00
})
export class AppModule {}