63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { GraphQLModule } from '@nestjs/graphql';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { AppController } from './app.controller';
|
|
import { AppResolver } from './app.resolver';
|
|
import { AppService } from './app.service';
|
|
import { ProjectsModule } from './projects/projects.module';
|
|
import { ReposModule } from './repos/repos.module';
|
|
import { PipelinesModule } from './pipelines/pipelines.module';
|
|
import { PipelineTasksModule } from './pipeline-tasks/pipeline-tasks.module';
|
|
import configuration from './commons/config/configuration';
|
|
import { RedisModule } from 'nestjs-redis';
|
|
|
|
@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],
|
|
useFactory: (configService: ConfigService) => ({
|
|
debug: configService.get<string>('env') !== 'prod',
|
|
playground: true,
|
|
autoSchemaFile: true,
|
|
installSubscriptionHandlers: true,
|
|
}),
|
|
inject: [ConfigService],
|
|
}),
|
|
ProjectsModule,
|
|
ReposModule,
|
|
PipelinesModule,
|
|
PipelineTasksModule,
|
|
RedisModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
useFactory: (configService: ConfigService) => ({
|
|
host: configService.get<string>('db.redis.host', 'localhost'),
|
|
port: configService.get<number>('db.redis.port', 6379),
|
|
password: configService.get<string>('db.redis.password', ''),
|
|
keyPrefix: configService.get<string>('db.redis.prefix', 'fennec'),
|
|
}),
|
|
inject: [ConfigService],
|
|
}),
|
|
],
|
|
controllers: [AppController],
|
|
providers: [AppService, AppResolver],
|
|
})
|
|
export class AppModule {}
|