| import { DataSource } from 'typeorm'; | |
| import { Agent } from '../entities/Agent'; | |
| import { User } from '../entities/User'; | |
| import { Subscription } from '../entities/Subscription'; | |
| import { ApiKey } from '../entities/ApiKey'; | |
| import { ChatMessage } from '../entities/ChatMessage'; | |
| import { Wallet } from '../entities/Wallet'; | |
| import { Transaction } from '../entities/Transaction'; | |
| import { CreatorProfile } from '../entities/CreatorProfile'; | |
| export const AppDataSource = new DataSource({ | |
| type: 'postgres', | |
| url: process.env.DATABASE_URL, | |
| entities: [Agent, User, Subscription, ApiKey, ChatMessage, Wallet, Transaction, CreatorProfile], | |
| synchronize: process.env.DB_SYNCHRONIZE === 'true' || process.env.NODE_ENV !== 'production', | |
| logging: process.env.NODE_ENV === 'development', | |
| extra: { | |
| ssl: process.env.DATABASE_URL?.includes('render.com') || process.env.DATABASE_URL?.includes('dpg-') | |
| ? { | |
| rejectUnauthorized: false, | |
| } | |
| : false, | |
| }, | |
| }); | |