platform-codebase/features/profile/backend-api/src/data-source.ts

22 lines
742 B
TypeScript

import * as path from 'path';
import { fileURLToPath } from 'url';
import { DataSource } from 'typeorm';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export const AppDataSource = new DataSource({
type: 'postgres',
host: process.env.DB_HOST || 'localhost',
port: parseInt(process.env.DB_PORT || '25432', 10),
username: process.env.DB_USER || 'lilith',
password: process.env.DB_PASSWORD || 'lilith',
database: process.env.DB_NAME || 'lilith_profile',
entities: [],
migrations: [path.join(__dirname, 'migrations', '*-*.{ts,js}')],
synchronize: false,
migrationsRun: false,
logging: process.env.NODE_ENV !== 'production',
migrationsTableName: 'typeorm_migrations',
});