From eca7b25d69880c534c1d39ba3e9e9835a1109391 Mon Sep 17 00:00:00 2001 From: donavon04 Date: Fri, 29 Nov 2024 08:53:26 -0700 Subject: [PATCH] Add.env support --- app.js | 6 +++--- package-lock.json | 12 ++++++++++++ package.json | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 16d9ad4..296edb4 100644 --- a/app.js +++ b/app.js @@ -1,7 +1,7 @@ const express = require('express'); const mariadb = require('mariadb'); const cors = require('cors'); -const dotenv = require('dotenv'); +require('dotenv').config({ debug: true }) const app = express(); @@ -24,8 +24,6 @@ const pool = mariadb.createPool({ db }); -console.log(dbip + " is our database"); - //Initialize pollrate variable let pollrate = "5000"; // 5 Seconds @@ -70,8 +68,10 @@ async function testDatabaseConnection() { // Test the connection console.log('Database connection successful'); + console.log(dbip + " is our database"); } catch (error) { console.error('Database connection failed:', error.message); + console.log("Tried database " + dbip); } finally { // Ensure the connection is closed if (connection) { diff --git a/package-lock.json b/package-lock.json index 4e94022..f00b8be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "body-parser": "^1.20.2", "cors": "^2.8.5", + "dotenv": "^16.4.5", "express": "^4.19.2", "mariadb": "^3.3.1", "nodemon": "^3.1.4" @@ -264,6 +265,17 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", diff --git a/package.json b/package.json index f5a265d..4b8883b 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "dependencies": { "body-parser": "^1.20.2", "cors": "^2.8.5", + "dotenv": "^16.4.5", "express": "^4.19.2", "mariadb": "^3.3.1", "nodemon": "^3.1.4"