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

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