-
Notifications
You must be signed in to change notification settings - Fork 0
/
ormconfig.ts
28 lines (24 loc) · 1 KB
/
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
import { ConnectionOptions } from 'typeorm';
import { join } from 'path';
import { config } from 'dotenv';
import { CustomNamingStrategy } from './mig/naming-strategy';
if (process.env.NODE_ENV !== 'production') config();
const commandPath = process.argv[0];
const command = commandPath.slice(commandPath.lastIndexOf('/') + 1);
if (command === 'ts-node') process.env.IS_TS_NODE = 'true';
export default {
type: 'postgres',
host: process.env.PG_HOST || 'localhost',
port: parseInt(process.env.PG_PORT, 10) || 5432,
username: process.env.PG_USER || 'postgres',
password: process.env.PG_PASSWORD || '',
database: process.env.PG_DATABASE || 'air_monitoring',
entities: [join(__dirname, 'src/entities', process.env.IS_TS_NODE ? '*.ts' : '*.js')],
migrations: [join(__dirname, 'mig/migrations', process.env.IS_TS_NODE ? '*.ts' : '*.js')],
cli: {
entitiesDir: 'src/entities',
migrationsDir: 'mig/migrations',
},
namingStrategy: new CustomNamingStrategy(),
synchronize: false,
} as ConnectionOptions;