-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata-source.ts
40 lines (36 loc) · 952 Bytes
/
data-source.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 { DataSource } from "typeorm";
import {
News,
User,
Watchlist,
SentimentResult,
StockInfo,
} from "arbitra-pulse-entities";
import * as dotenv from "dotenv";
// load environment variables from .env file
dotenv.config();
const AppDataSource = new DataSource({
type: "postgres",
host: process.env.DB_HOST || "",
port: parseInt(process.env.DB_PORT || "", 10),
username: process.env.DB_USERNAME || "",
password: process.env.DB_PASSWORD || "",
database: process.env.DB_DATABASE || "",
synchronize: true,
logging: true,
entities: [User, Watchlist, News, SentimentResult, StockInfo],
migrations: [],
ssl: {
rejectUnauthorized: false,
},
});
// initialize the DataSource
AppDataSource.initialize()
.then(() => {
console.log("Data Source has been initialized!");
})
.catch((err) => {
console.error("Error during Data Source initialization", err);
});
// export the datasource for global usage
export default AppDataSource;