Files
edr-platform/apps/edr-gps-tracker/src/config/database.config.ts
natib21 15fc21a6c9 gps
2026-07-10 15:23:49 +00:00

29 lines
1.1 KiB
TypeScript

import { registerAs } from "@nestjs/config";
import { TypeOrmModuleOptions } from "@nestjs/typeorm";
import { GpsDevice } from "../gps/entities/gps-device.entity";
import { GpsPosition } from "../gps/entities/gps-position.entity";
/**
* DB config for the GPS ingester. Points at the SAME database as
* @edr/freight-api and touches only the two GPS tables, which are explicitly
* schema-qualified to `freight` on the entities — so no search_path handler is
* needed here. This app NEVER runs migrations or synchronize: @edr/freight-api
* owns the schema (the AddGpsTracking migration creates these tables).
*/
export default registerAs("database", (): TypeOrmModuleOptions => {
return {
type: "postgres",
host: process.env.DB_HOST ?? "localhost",
port: parseInt(process.env.DB_PORT ?? "5433", 10),
username: process.env.DB_USER ?? "postgres",
password: process.env.DB_PASSWORD ?? "",
database: process.env.DB_NAME ?? "edr_freight",
entities: [GpsDevice, GpsPosition],
migrations: [],
migrationsRun: false,
synchronize: false,
logging: process.env.TYPEORM_LOGGING === "true" ? true : ["error", "warn"],
};
});