|
|
|
import { Module } from '@nestjs/common'
|
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config'
|
|
|
|
import { TypeOrmModule } from '@nestjs/typeorm'
|
|
|
|
import * as Joi from 'joi'
|
|
|
|
import { ScheduleModule } from '@nestjs/schedule'
|
|
|
|
|
|
|
|
import { AuthModule } from './auth/auth.module'
|
|
|
|
import { ChatModule } from './chat/chat.module'
|
|
|
|
import { PongModule } from './pong/pong.module'
|
|
|
|
import { UsersModule } from './users/users.module'
|
|
|
|
|
|
|
|
@Module({
|
|
|
|
imports: [
|
|
|
|
ScheduleModule.forRoot(),
|
|
|
|
ConfigModule.forRoot({
|
|
|
|
validationSchema: Joi.object({
|
|
|
|
POSTGRES_HOST: Joi.string().required(),
|
|
|
|
POSTGRES_PORT: Joi.number().required(),
|
|
|
|
POSTGRES_USER: Joi.string().required(),
|
|
|
|
POSTGRES_PASSWORD: Joi.string().required(),
|
|
|
|
POSTGRES_DB: Joi.string().required(),
|
|
|
|
MAIL_USER: Joi.string().required(),
|
|
|
|
MAIL_PASSWORD: Joi.string().required(),
|
|
|
|
JWT_SECRET: Joi.string().required(),
|
|
|
|
JWT_EXPIRATION_TIME: Joi.string().required(),
|
|
|
|
HOST: Joi.string().required(),
|
|
|
|
FRONT_PORT: Joi.number().required(),
|
|
|
|
BACK_PORT: Joi.number().required(),
|
|
|
|
HASH_SALT: Joi.number().required()
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
TypeOrmModule.forRootAsync({
|
|
|
|
imports: [ConfigModule],
|
|
|
|
inject: [ConfigService],
|
|
|
|
useFactory: (configService: ConfigService) => ({
|
|
|
|
type: 'postgres',
|
|
|
|
host: configService.get<string>('POSTGRES_HOST'),
|
|
|
|
port: configService.get<number>('POSTGRES_PORT'),
|
|
|
|
username: configService.get<string>('POSTGRES_USER'),
|
|
|
|
password: configService.get<string>('POSTGRES_PASSWORD'),
|
|
|
|
database: configService.get<string>('POSTGRES_DB'),
|
|
|
|
jwt_secret: configService.get<string>('JWT_SECRET'),
|
|
|
|
autoLoadEntities: true,
|
|
|
|
synchronize: true
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
AuthModule,
|
|
|
|
ChatModule,
|
|
|
|
PongModule,
|
|
|
|
UsersModule
|
|
|
|
]
|
|
|
|
})
|
|
|
|
export class AppModule {}
|