Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
NODE_ENV=development
APP_PORT=3000

DATABASE_URL=
DB_SSL=false

POSTGRES_DB=neph_db
POSTGRES_USER=neph_user
POSTGRES_PASSWORD=neph_pass
Expand All @@ -14,4 +17,5 @@ SMTP_PORT=587
SMTP_USER=your_gmail@gmail.com
SMTP_PASS=your_gmail_app_password

APP_URL=http://localhost:3000
APP_URL=http://localhost:3000
FRONTEND_URL=http://localhost:5173
4 changes: 3 additions & 1 deletion backend/src/config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ function readNumber(value, fallback) {

const env = {
nodeEnv: process.env.NODE_ENV || 'development',
appPort: readNumber(process.env.APP_PORT, 3000),
appPort: readNumber(process.env.APP_PORT || process.env.PORT, 3000),
database: {
url: process.env.DATABASE_URL || '',
host: process.env.POSTGRES_HOST || 'localhost',
port: readNumber(process.env.POSTGRES_PORT, 5432),
database: process.env.POSTGRES_DB || 'neph_db',
user: process.env.POSTGRES_USER || 'neph_user',
password: process.env.POSTGRES_PASSWORD || 'neph_pass',
ssl: (process.env.DB_SSL || 'false').toLowerCase() === 'true',
},
jwt: {
secret: process.env.JWT_SECRET || 'dev-secret-123',
Expand Down
22 changes: 15 additions & 7 deletions backend/src/db/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ const { Pool } = require('pg');

const { env } = require('../config/env');

const pool = new Pool({
host: env.database.host,
port: env.database.port,
database: env.database.database,
user: env.database.user,
password: env.database.password,
});
const poolConfig = env.database.url
? {
connectionString: env.database.url,
ssl: env.database.ssl ? { rejectUnauthorized: false } : undefined,
}
: {
host: env.database.host,
port: env.database.port,
database: env.database.database,
user: env.database.user,
password: env.database.password,
ssl: env.database.ssl ? { rejectUnauthorized: false } : undefined,
};

const pool = new Pool(poolConfig);

async function query(text, params = []) {
return pool.query(text, params);
Expand Down
Empty file added npm
Empty file.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.