Skip to content

Commit c1dfc02

Browse files
committed
Update database connection method
1 parent 5aaf187 commit c1dfc02

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ DISCORD_SERVER_INVITE=your-discord-server-invite
3838
PORT=your-custom-backend-port
3939
SESSION_SECRET=server-session-secret
4040
BACKEND_SERVER_URL=backend-server-url-without-port
41-
POSTGRES_USERNAME=your-postgres-username (postgres if not changed)
42-
POSTGRES_PASSWORD=your-postgres-password
43-
DB_HOST= (only if you are not using PostgreSQL locally)
41+
DATABASE_URL=postgres-connection-string (eg. postgres://postgres:postgres@localhost:5432/postgres)
4442
GRAFANA_TOKEN=your-grafana-authorization-token
4543
GRAFANA_URL=your-server-url/grafana/your-dashboard-specific-stuff
4644
GRAFANA_PANEL_ID=your-grafana-panel-id

src/db/dbInit.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
require("dotenv").config();
22
const Sequelize = require("sequelize");
3-
const password = process.env.POSTGRES_PASSWORD;
43

5-
let username = process.env.POSTGRES_USERNAME;
6-
if (!username) {
7-
username = "postgres";
8-
}
4+
const dbUrl = process.env.DATABASE_URL;
95

10-
const sequelize = new Sequelize("postgres", username, password, {
11-
dialect: "postgres",
12-
host: process.env.DB_HOST || "localhost",
13-
logging: false,
14-
});
6+
const sequelize = new Sequelize(dbUrl, { logging: false });
157

168
const Course = require("./models/Course")(sequelize, Sequelize.DataTypes);
179
const Channel = require("./models/Channel")(sequelize, Sequelize.DataTypes);

0 commit comments

Comments
 (0)