-
Notifications
You must be signed in to change notification settings - Fork 0
/
ormconfig.ts
31 lines (25 loc) · 899 Bytes
/
ormconfig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import './src/boilerplate.polyfill';
import * as dotenv from 'dotenv';
import { SnakeNamingStrategy } from './src/snake-naming.strategy';
if (!(<any>module).hot /* for webpack HMR */) {
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
}
dotenv.config({
path: `.${process.env.NODE_ENV}.env`,
});
// Replace \\n with \n to support multiline strings in AWS
for (const envName of Object.keys(process.env)) {
process.env[envName] = process.env[envName].replace(/\\n/g, '\n');
}
const options = {
type: 'postgres',
host: process.env.DB_HOST,
port: +process.env.DB_PORT,
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
namingStrategy: new SnakeNamingStrategy(),
entities: ['src/modules/**/*.entity{.ts,.js}'],
migrations: ['src/migrations/*{.ts,.js}'],
};
module.exports = options;