19 lines
508 B
TypeScript
19 lines
508 B
TypeScript
import postgres from "postgres";
|
|
import dotenv from "dotenv";
|
|
|
|
if (dotenv.config({ path: ".local.env" }).error) {
|
|
console.log("No .local.env file found, trying .env");
|
|
if (dotenv.config().error) {
|
|
console.log("No .env file found, using system environment variables");
|
|
}
|
|
}
|
|
|
|
const sql = postgres({
|
|
host: process.env.DB_HOST,
|
|
port: Number(process.env.DB_PORT) || 5432,
|
|
database: process.env.DB_NAME,
|
|
username: process.env.DB_USER,
|
|
password: process.env.DB_PASSWORD,
|
|
});
|
|
|
|
export default sql;
|