database.ts47 lines, 1.4 KB
| 1 | import { Video } from "../entities/video.entity"; |
| 2 | import { User } from "../entities/user.entity"; |
| 3 | import { DataSource } from "typeorm"; |
| 4 | import { Transcription } from "../entities/transcription.entity"; |
| 5 | import { Analysis } from "../entities/analysis.entity"; |
| 6 | import { SubscriptionPlan } from "../entities/subscription-plan.entity"; |
| 7 | import { UserSubscription } from "../entities/user-subscription.entity"; |
| 8 | |
| 9 | export const AppDataSource = new DataSource( |
| 10 | process.env.DATABASE_URL |
| 11 | ? { |
| 12 | type: "postgres", |
| 13 | url: process.env.DATABASE_URL, |
| 14 | entities: [ |
| 15 | User, |
| 16 | Video, |
| 17 | Transcription, |
| 18 | Analysis, |
| 19 | SubscriptionPlan, |
| 20 | UserSubscription, |
| 21 | ], |
| 22 | migrations: [], |
| 23 | subscribers: [], |
| 24 | synchronize: true, |
| 25 | } |
| 26 | : { |
| 27 | type: "postgres", |
| 28 | host: process.env.DB_HOST || "localhost", |
| 29 | port: parseInt(process.env.DB_PORT || "5432"), |
| 30 | username: process.env.DB_USERNAME || "postgres", |
| 31 | password: process.env.DB_PASSWORD || "postgres", |
| 32 | database: process.env.DB_DATABASE || "video_summarizer", |
| 33 | // logging: ["query", "error"], |
| 34 | entities: [ |
| 35 | User, |
| 36 | Video, |
| 37 | Transcription, |
| 38 | Analysis, |
| 39 | SubscriptionPlan, |
| 40 | UserSubscription, |
| 41 | ], |
| 42 | migrations: [], |
| 43 | subscribers: [], |
| 44 | synchronize: true, |
| 45 | // dropSchema: true, |
| 46 | } |
| 47 | ); |