add support for reading database url from password

This commit is contained in:
sid palas
2023-02-03 16:29:48 -05:00
parent 732ee2f648
commit f709ee9abd
2 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"io/ioutil"
"log"
"os"
"time"
@ -11,7 +12,16 @@ import (
)
func init() {
errDB := database.InitDB(os.Getenv("DATABASE_URL"))
databaseUrl := os.Getenv("DATABASE_URL")
if databaseUrl == "" {
content, err := ioutil.ReadFile(os.Getenv("DATABASE_URL_FILE"))
if err != nil {
log.Fatal(err)
}
databaseUrl = string(content)
}
errDB := database.InitDB(databaseUrl)
if errDB != nil {
log.Fatalf("⛔ Unable to connect to database: %v\n", errDB)
} else {

View File

@ -1,7 +1,13 @@
const fs = require('fs');
const { Pool } = require('pg');
databaseUrl =
process.env.DATABASE_URL ||
fs.readFileSync(process.env.DATABASE_URL_FILE, 'utf8');
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
connectionString: databaseUrl,
});
// the pool will emit an error on behalf of any idle clients