auth
This commit is contained in:
32
api/src/shared/database/database.module.ts
Normal file
32
api/src/shared/database/database.module.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { SSOUser, User } from 'src/model/entitites';
|
||||
import { SsoUserRepository, UserRepository } from 'src/model/repositories';
|
||||
|
||||
const ENTITIES = [User, SSOUser];
|
||||
const REPOSITORIES = [UserRepository, SsoUserRepository];
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forRootAsync({
|
||||
useFactory: () => ({
|
||||
type: 'mysql',
|
||||
host: process.env.DATABASE_HOST,
|
||||
port: parseInt(process.env.DATABASE_PORT) || 3306,
|
||||
username: process.env.MYSQL_USER,
|
||||
password: process.env.MYSQL_PASSWORD,
|
||||
database: process.env.MYSQL_DATABASE,
|
||||
synchronize: true,
|
||||
autoLoadEntities: true,
|
||||
retryAttempts: 5,
|
||||
retryDelay: 10000,
|
||||
logging: ['error'],
|
||||
logger: 'file',
|
||||
entities: [...ENTITIES],
|
||||
}),
|
||||
}),
|
||||
],
|
||||
providers: [...REPOSITORIES],
|
||||
exports: [TypeOrmModule, ...REPOSITORIES],
|
||||
})
|
||||
export class DatabaseModule {}
|
||||
Reference in New Issue
Block a user