-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathormconfig.ts
More file actions
29 lines (24 loc) · 1.04 KB
/
ormconfig.ts
File metadata and controls
29 lines (24 loc) · 1.04 KB
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
import './src/boilerplate.polyfill';
import dotenv from 'dotenv';
import type { DataSourceOptions } from 'typeorm';
import { DataSource } from 'typeorm';
import type { SeederOptions } from 'typeorm-extension';
import { UserSeeder } from './src/database/seeds';
import { SubscriptionTransactionSubscriber, UserSubscriber } from './src/entity-subscribers';
import { SnakeNamingStrategy } from './src/snake-naming.strategy';
dotenv.config();
const options: DataSourceOptions & SeederOptions = {
type: 'postgres',
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT),
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
synchronize: Boolean(process.env.ENABLE_SYNCHRONIZE),
namingStrategy: new SnakeNamingStrategy(),
subscribers: [UserSubscriber, SubscriptionTransactionSubscriber],
entities: ['src/modules/**/*.entity{.ts,.js}'],
migrations: ['src/database/migrations/*{.ts,.js}'],
seeds: [UserSeeder]
};
export const dataSource = new DataSource(options);