Skip to content

Commit

Permalink
Using environment config variables
Browse files Browse the repository at this point in the history
  • Loading branch information
henrypalacios committed Dec 21, 2023
1 parent d01be3a commit 9578ede
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/services/squidDB/Database.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { Pool, QueryResult } from "pg";

import {
NEXT_DB_HOST,
NEXT_DB_NAME,
NEXT_DB_PASS,
NEXT_DB_PORT,
NEXT_DB_USER,
} from "@/config/squid";

export class Database {
private pool: Pool;

constructor() {
this.pool = new Pool({
user: process.env.NEXT_DB_USER || "appuser",
password: process.env.NEXT_DB_PASS || "appuser",
host: process.env.NEXT_DB_HOST || "localhost",
port: process.env.NEXT_DB_PORT
? parseInt(process.env.NEXT_DB_PORT)
: 23798,
database: process.env.NEXT_DB_NAME || "squid",
user: NEXT_DB_USER,
password: NEXT_DB_PASS,
host: NEXT_DB_HOST,
port: NEXT_DB_PORT,
database: NEXT_DB_NAME,
});
}

Expand Down

0 comments on commit 9578ede

Please sign in to comment.