Add.env support

This commit is contained in:
Donavon McDowell 2024-11-29 08:53:26 -07:00
parent b1fa4b6238
commit eca7b25d69
3 changed files with 16 additions and 3 deletions

6
app.js
View File

@ -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) {

12
package-lock.json generated
View File

@ -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",

View File

@ -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"