You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

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";
2 years ago
@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(),
2 years ago
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,
],
2 years ago
})
export class AppModule {}