28 lines
925 B
TypeScript
Executable File
28 lines
925 B
TypeScript
Executable File
import { join } from "path";
|
|
|
|
import { config } from "dotenv";
|
|
import { DataSource } from "typeorm";
|
|
|
|
import { TicketMessageAttachment } from "../src/modules/tickets/entities/ticket-message-attachment";
|
|
config();
|
|
|
|
const { DB_HOST, DB_NAME, DB_PASS, DB_PORT, DB_USER, NODE_ENV } = process.env;
|
|
const IS_PROD = NODE_ENV === "production";
|
|
const PATH = IS_PROD ? "dist" : "src";
|
|
|
|
export const connectionSource = new DataSource({
|
|
type: "postgres",
|
|
host: DB_HOST as string,
|
|
port: parseInt(DB_PORT as string),
|
|
username: DB_USER,
|
|
password: DB_PASS,
|
|
database: DB_NAME,
|
|
logging: true,
|
|
entities: [join(process.cwd(), PATH, "modules/**/*.entity{.ts,.js}"), TicketMessageAttachment],
|
|
migrations: [join(process.cwd(), "database/migrations/*{.ts,.js}")],
|
|
synchronize: false,
|
|
migrationsTableName: "typeorm_migrations",
|
|
migrationsRun: false,
|
|
});
|
|
console.log(join(process.cwd(), PATH, "modules/**/*.entity{.ts,.js}"));
|