52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { AppController } from './app.controller';
|
|
import { AppService } from './app.service';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { UserModule } from './user/user.module';
|
|
import { AuthModule } from './auth/auth.module';
|
|
import { User } from './entity/user';
|
|
import { UserGroup } from './entity/user-group';
|
|
import { UserRole } from './entity/user-role';
|
|
import { LoggerModule } from './logger/logger.module';
|
|
import { EventType } from './entity/event-type.entity';
|
|
import { EventTypesModule } from './event-type/event-type.module';
|
|
import { Product } from './entity/product.entity';
|
|
import { ProductsModule } from './product/products.module';
|
|
import { Event } from "./entity/event.entity";
|
|
import { EventsModule } from "./event/events.module";
|
|
|
|
const moduleTypeOrm = TypeOrmModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: (configService: ConfigService) => {
|
|
return {
|
|
type: 'postgres',
|
|
host: configService.get<string>('DATABASE_HOST'),
|
|
port: parseInt(configService.get<string>('DATABASE_PORT') as string, 10),
|
|
username: configService.get<string>('DATABASE_USER'),
|
|
password: configService.get<string>('DATABASE_PASS'),
|
|
database: configService.get<string>('DATABASE_NAME'),
|
|
entities: [User, UserGroup, UserRole, EventType, Product, Event],
|
|
logging: true,
|
|
// synchronize: true,
|
|
};
|
|
},
|
|
});
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot(),
|
|
moduleTypeOrm,
|
|
UserModule,
|
|
AuthModule,
|
|
LoggerModule,
|
|
EventTypesModule,
|
|
ProductsModule,
|
|
EventsModule
|
|
],
|
|
controllers: [AppController],
|
|
providers: [AppService],
|
|
})
|
|
export class AppModule {}
|