-
Notifications
You must be signed in to change notification settings - Fork 0
/
ormconfig.ts
40 lines (37 loc) · 1.27 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
29
30
31
32
33
34
35
36
37
38
39
40
import { TypeOptions } from 'class-transformer';
import * as dotenv from 'dotenv';
import "reflect-metadata"
import { User } from 'src/auth/user.entity';
import { FoodItem } from 'src/food-item/food_item.entity';
import { DataSource, DataSourceOptions } from 'typeorm';
dotenv.config();
export const ormCredintials: DataSourceOptions = {
type: 'postgres',
host: process.env.DB_HOST,
port: process.env.DB_PORT ? parseInt(process.env.DB_PORT, 10) : null,
database: process.env.DB_NAME,
username: process.env.DB_USER,
password: process.env.DB_PASS,
entities: [__dirname + '/src/**/*.entity{.ts,.js}'],
migrations: [__dirname + '/migrations/**/*{.ts,.js}'],
migrationsRun: false,
synchronize: false,
}
const typeOrmConfig = new DataSource({
type: 'postgres',
host: process.env.DB_HOST,
port: process.env.DB_PORT ? parseInt(process.env.DB_PORT, 10) : null,
database: process.env.DB_NAME,
username: process.env.DB_USER,
password: process.env.DB_PASS,
entities: [__dirname + '/src/**/*.entity{.ts,.js}'],
migrations: [__dirname + '/migrations/**/*{.ts,.js}'],
migrationsRun: false,
synchronize: false,
});
typeOrmConfig.initialize()
.then(() => {
console.log("initialized data source");
})
.catch((error) => console.log(error))
export default typeOrmConfig;