Last active
August 11, 2024 16:55
-
-
Save paulodutra/5d582761cf1c5e611f5c6215f009b24b to your computer and use it in GitHub Desktop.
Mysql database config Typeorm Nestjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { registerAs } from '@nestjs/config'; | |
import { TypeOrmModuleOptions } from '@nestjs/typeorm'; | |
export const mysqlDatabaseConfig = registerAs( | |
'database.mysql', | |
(): TypeOrmModuleOptions => ({ | |
type: 'mysql', | |
host: process.env.DB_HOST, | |
username: process.env.DB_USERNAME, | |
password: process.env.DB_PASSWORD, | |
database: process.env.DB_DATABASE, | |
port: Number(process.env.DB_PORT), | |
entities: [ | |
__dirname + | |
'/../../../infrastructure/database/entities/*.entity{.ts,.js}', | |
], | |
migrations: [ | |
__dirname + | |
'/../../../infrastructure/database/migrations/*.migration{.ts,.js}', | |
], | |
synchronize: true, | |
logging: ['error', 'query', 'warn', 'info', 'schema', 'log'], | |
}), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment