refactor: Remove hardcoded values from codebase, converting to environment variables

This commit is contained in:
2025-08-19 15:51:47 -05:00
parent 9637221240
commit e8b55caaed

View File

@@ -5,13 +5,14 @@ const { Pool } = require('pg');
const rateLimit = require('express-rate-limit');
require('dotenv').config();
const app = express();
const port = 3000;
const port = process.env.SERVER_PORT || 3000;
// Middleware to parse incoming JSON data from the frontend
app.use(express.json());
// Middleware to serve static files (like index.html, styles.css, script.js)
app.use(express.static(path.join(__dirname, 'public')));
const STATIC_DIR = process.env.STATIC_DIR || 'public'
app.use(express.static(path.join(__dirname, STATIC_DIR)));
// Database connection pool setup using environment variables for security
const pool = new Pool({
@@ -24,8 +25,8 @@ const pool = new Pool({
// Nodemailer transporter setup for sending emails
const transporter = nodemailer.createTransport({
host: 'smtp-relay.brevo.com',
port: 2525,
host: process.env.EMAIL_HOST,
port: process.env.EMAIL_PORT,
secure: false,
requireTLS: true,
auth: {