From d0199b5a9118d208ea62ed80a805ac7dffeedc3a Mon Sep 17 00:00:00 2001 From: Apher Date: Sun, 28 Jun 2026 23:00:25 +0000 Subject: [PATCH] Config fiddling --- src/config/auth.config.js | 2 +- src/server.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/config/auth.config.js b/src/config/auth.config.js index 35d751f..678568a 100644 --- a/src/config/auth.config.js +++ b/src/config/auth.config.js @@ -1,3 +1,3 @@ module.exports = { - secret: process.env.JWT_SECRET + jwt_secret: process.env.JWT_SECRET }; \ No newline at end of file diff --git a/src/server.js b/src/server.js index 420d3fc..3e68aea 100644 --- a/src/server.js +++ b/src/server.js @@ -19,22 +19,22 @@ const createApp = () => { // CORS restrict in production (set ALLOWED_ORIGINS env to comma-separated list) const corsOptions = { - origin: config.NODE_ENV === "production" - ? (config.ALLOWED_ORIGINS || "").split(",").map(s => s.trim()) + origin: config.node_env === "production" + ? (config.allowed_origins || "").split(",").map(s => s.trim()) : true, optionsSuccessStatus: 200 }; app.use(cors(corsOptions)); // Logging verbose in dev - app.use(morgan(config.NODE_ENV === "production" ? "combined" : "dev")); + app.use(morgan(config.node_env === "production" ? "combined" : "dev")); // Body parsing with size limits app.use(express.json({limit: "10kb"})); app.use(express.urlencoded({extended: false, limit: "10kb"})); // Apply rate limiting in production - if (config.NODE_ENV === "production") { + if (config.node_env === "production") { app.use(rateLimit({ windowMs: 15 * 60 * 1000, // 15 minutes max: 100, // limit per IP @@ -75,12 +75,13 @@ const initRoles = async () => { const start = async () => { try { // Validate important env vars + console.log(authConfig.jwt_secret); if (!authConfig.secret) { console.warn("JWT_SECRET not set. Ensure secure secret in production."); } // Sync DB (not forced in production) - const doForce = config.FORCE_DB_SYNC === "true" && config.NODE_ENV !== "production"; + const doForce = config.force_db_sync === "true" && config.node_env !== "production"; await sequelize.authenticate(); await sequelize.sync({force: doForce}); if (doForce) console.info("Database dropped and resynced (force=true)."); @@ -90,7 +91,7 @@ const start = async () => { const app = createApp(); // Set port and listen - const PORT = parseInt(config.PORT, 10) || 5000; + const PORT = parseInt(config.port, 10) || 5000; const server = app.listen(PORT, () => { console.log(`Server listening on port ${PORT}`); });