feat: graphql + typeorm + config + postgresql
This commit is contained in:
@@ -1,10 +1,42 @@
|
||||
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 configuration from './commons/config/configuration';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
load: [configuration],
|
||||
}),
|
||||
TypeOrmModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
useFactory: (cnfigService: ConfigService) => ({
|
||||
type: 'postgres',
|
||||
host: cnfigService.get<string>('db.postgres.host'),
|
||||
port: cnfigService.get<number>('db.postgres.port'),
|
||||
username: cnfigService.get<string>('db.postgres.username'),
|
||||
password: cnfigService.get<string>('db.postgres.password'),
|
||||
database: cnfigService.get<string>('db.postgres.database'),
|
||||
synchronize: true,
|
||||
autoLoadEntities: true,
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
GraphQLModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
useFactory: (cnfigService: ConfigService) => ({
|
||||
debug: cnfigService.get<string>('env') !== 'prod',
|
||||
playground: true,
|
||||
autoSchemaFile: true,
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
providers: [AppService, AppResolver],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
Reference in New Issue
Block a user