Repository navigation
Expand file tree
/
Copy pathdata-source.ts
More file actions
39 lines (39 loc) · 1.39 KB
/
Copy pathdata-source.ts
File metadata and controls
39 lines (39 loc) · 1.39 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
30
31
32
33
34
35
36
37
38
39
import 'reflect-metadata';
import { DataSourceOptions } from 'typeorm';
import { Customer } from '../customers/entities/customer.entity';
import { Product } from '../products/entities/product.entity';
import { Order } from '../orders/entities/order.entity';
import { OrderItem } from '../orders/entities/orderitem.entity';
import { required, integer } from '../config';
import { InitialSchema1793894400000 } from './migrations/1793894400000-InitialSchema';
import { Authentication1793980800000 } from './migrations/1793980800000-Authentication';
import { User } from '../users/entities/user.entity';
import { AuthSession, RefreshToken } from '../auth/entities/session.entity';
export function databaseOptions(): DataSourceOptions {
return {
type: 'postgres',
ssl: process.env.DB_SSL === 'true' ? { rejectUnauthorized: true } : false,
host: required('DB_HOST'),
port: integer('DB_PORT', 5432),
username: required('DB_USER'),
password: required('DB_PASSWORD'),
database: required('DB_NAME'),
entities: [
Customer,
Product,
Order,
OrderItem,
User,
AuthSession,
RefreshToken,
],
migrations: [InitialSchema1793894400000, Authentication1793980800000],
extra: {
max: 10,
connectionTimeoutMillis: 5000,
options: '-c statement_timeout=15000 -c lock_timeout=10000',
},
synchronize: false,
migrationsRun: false,
};
}