2021-01-31 11:15:21 +08:00
|
|
|
import { Module } from '@nestjs/common';
|
2021-01-31 13:32:15 +08:00
|
|
|
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';
|
2021-01-31 13:32:15 +08:00
|
|
|
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';
|
2021-02-19 13:11:03 +08:00
|
|
|
import { ReposModule } from './repos/repos.module';
|
2021-01-31 13:32:15 +08:00
|
|
|
import configuration from './commons/config/configuration';
|
2021-01-31 11:15:21 +08:00
|
|
|
|
|
|
|
@Module({
|
2021-01-31 13:32:15 +08:00
|
|
|
imports: [
|
|
|
|
ConfigModule.forRoot({
|
|
|
|
load: [configuration],
|
|
|
|
}),
|
|
|
|
TypeOrmModule.forRootAsync({
|
|
|
|
imports: [ConfigModule],
|
2021-02-24 11:11:47 +08:00
|
|
|
useFactory: (configService: ConfigService) => ({
|
2021-01-31 13:32:15 +08:00
|
|
|
type: 'postgres',
|
2021-02-24 11:11:47 +08:00
|
|
|
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'),
|
2021-01-31 13:32:15 +08:00
|
|
|
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',
|
2021-01-31 13:32:15 +08:00
|
|
|
playground: true,
|
|
|
|
autoSchemaFile: true,
|
|
|
|
}),
|
|
|
|
inject: [ConfigService],
|
|
|
|
}),
|
2021-01-31 19:42:17 +08:00
|
|
|
ProjectsModule,
|
2021-02-19 13:11:03 +08:00
|
|
|
ReposModule,
|
2021-01-31 13:32:15 +08:00
|
|
|
],
|
2021-01-31 11:15:21 +08:00
|
|
|
controllers: [AppController],
|
2021-01-31 13:32:15 +08:00
|
|
|
providers: [AppService, AppResolver],
|
2021-01-31 11:15:21 +08:00
|
|
|
})
|
|
|
|
export class AppModule {}
|