Package updates/cleanup

This commit is contained in:
Sean Edmunds
2025-06-26 16:06:20 -05:00
parent 88081d1969
commit df32369998
4 changed files with 13 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
DB_HOST='127.0.0.1' DB_HOST='127.0.0.1'
DB_USER='triggeradmin' DB_USER='triggeradmin'
DB_PASS='trigger' DB_PASS='trigger'
DB_PORT='3306'
API_PORT='5000'

8
package-lock.json generated
View File

@@ -10,7 +10,7 @@
"dependencies": { "dependencies": {
"body-parser": "^2.2.0", "body-parser": "^2.2.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^16.5.0", "dotenv": "^16.6.0",
"express": "^5.1.0", "express": "^5.1.0",
"mariadb": "^3.4.2", "mariadb": "^3.4.2",
"multer": "^2.0.1", "multer": "^2.0.1",
@@ -230,9 +230,9 @@
} }
}, },
"node_modules/dotenv": { "node_modules/dotenv": {
"version": "16.5.0", "version": "16.6.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.0.tgz",
"integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==", "integrity": "sha512-Omf1L8paOy2VJhILjyhrhqwLIdstqm1BvcDPKg4NGAlkwEu9ODyrFbvk8UymUOMCT+HXo31jg1lArIrVAAhuGA==",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"engines": { "engines": {
"node": ">=12" "node": ">=12"

View File

@@ -4,7 +4,7 @@
"dependencies": { "dependencies": {
"body-parser": "^2.2.0", "body-parser": "^2.2.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^16.5.0", "dotenv": "^16.6.0",
"express": "^5.1.0", "express": "^5.1.0",
"mariadb": "^3.4.2", "mariadb": "^3.4.2",
"multer": "^2.0.1", "multer": "^2.0.1",

View File

@@ -13,13 +13,11 @@ const pool = mariadb.createPool({
host: process.env.DB_HOST, host: process.env.DB_HOST,
user: process.env.DB_USER, user: process.env.DB_USER,
password: process.env.DB_PASS, password: process.env.DB_PASS,
port: process.env.DB_PORT,
connectionLimit: 5, connectionLimit: 5,
}); });
// initializing app
const app = express(); const app = express();
// initializing cors middleware for all routes
const corsOptions = { const corsOptions = {
origin: "*", origin: "*",
credentials: true, credentials: true,
@@ -372,6 +370,7 @@ app.patch("/trigger/api/bookmarkCategoryOrder", async (req, res) => {
res.send({ status: "success" }); res.send({ status: "success" });
conn.end(); conn.end();
}); });
////////////////////////////////////////////// //////////////////////////////////////////////
// Provider Data // // Provider Data //
////////////////////////////////////////////// //////////////////////////////////////////////
@@ -555,7 +554,6 @@ app.patch("/trigger/api/backgrounds", async (req, res) => {
`../TriggerFrontend/backgrounds/${req.body.newFileName}`, `../TriggerFrontend/backgrounds/${req.body.newFileName}`,
(err) => { (err) => {
if (err) throw err; if (err) throw err;
console.log("Rename complete!");
}, },
); );
const conn = await pool.getConnection(); const conn = await pool.getConnection();
@@ -573,17 +571,17 @@ app.patch("/trigger/api/backgrounds", async (req, res) => {
app.delete("/trigger/api/backgrounds", async (req, res) => { app.delete("/trigger/api/backgrounds", async (req, res) => {
fs.rm(`../TriggerFrontend/backgrounds/${req.body.fileName}`, (_err) => { fs.rm(`../TriggerFrontend/backgrounds/${req.body.fileName}`, (_err) => {
res.status(200).send({ status: "success" }); if (_err) throw _err;
}); });
const conn = await pool.getConnection(); const conn = await pool.getConnection();
const query = `UPDATE trigger_database.themes SET backgroundImage = 'none' WHERE backgroundImage = ${escapeString(req.body.fileName)};`; const query = `UPDATE trigger_database.themes SET backgroundImage = 'none' WHERE backgroundImage = ${escapeString(req.body.fileName)};`;
conn conn
.query(query) .query(query)
.then((_rows) => { .then((_rows) => {
console.log("success"); res.status(200).send({ status: "success" });
}) })
.catch((err) => { .catch((err) => {
console.log(err); res.status(500).send({ error: err });
}); });
conn.end(); conn.end();
}); });
@@ -610,7 +608,6 @@ app.post("/trigger/api/wolClients", async (req, res) => {
res.status(200).send({ status: "success" }); res.status(200).send({ status: "success" });
}) })
.catch((err) => { .catch((err) => {
console.log(err);
res.status(500).send({ error: err }); res.status(500).send({ error: err });
}); });
conn.end(); conn.end();
@@ -625,7 +622,6 @@ app.patch("/trigger/api/wolClients", async (req, res) => {
res.status(200).send({ status: "success" }); res.status(200).send({ status: "success" });
}) })
.catch((err) => { .catch((err) => {
console.log(err);
res.status(500).send({ error: err }); res.status(500).send({ error: err });
}); });
conn.end(); conn.end();
@@ -693,5 +689,4 @@ app.delete("/trigger/api/searchHistory", async (req, res) => {
conn.end(); conn.end();
}); });
// app is listening on port 5000 app.listen(process.env.API_PORT, "0.0.0.0", () => {});
app.listen(5000, "0.0.0.0", () => {});