Added themePlaylist endpoints

This commit is contained in:
Sean Edmunds
2025-03-13 17:00:54 -05:00
parent 39f2411b45
commit 65116277e9

View File

@@ -347,6 +347,57 @@ app.get("/trigger/api/backgrounds", async (req, res) => {
});
});
app.get("/trigger/api/themePlaylists", async (req, res) => {
const conn = await pool.getConnection();
const query = "SELECT * FROM trigger_database.themePlaylists;";
conn.query(query).then((rows) => {
res.status(200).send(rows);
});
conn.end();
});
app.post("/trigger/api/themePlaylists", async (req, res) => {
const conn = await pool.getConnection();
const query = `INSERT INTO trigger_database.themePlaylists (name, themeList) VALUES ('${sqlEscape(req.body.name)}','${sqlEscape(req.body.themeList)}');`;
conn
.query(query)
.then((rows) => {
res.status(200).send({ status: "success" });
})
.catch((err) => {
res.status(500).send({ error: err });
});
conn.end();
});
app.patch("/trigger/api/themePlaylists", async (req, res) => {
const conn = await pool.getConnection();
const query = `UPDATE trigger_database.themePlaylists SET name = '${sqlEscape(req.body.name)}', themeList = '${req.body.themeList}' WHERE id = '${req.body.id}';`;
conn
.query(query)
.then((rows) => {
res.status(200).send({ status: "success" });
})
.catch((err) => {
res.status(500).send({ error: err });
});
conn.end();
});
app.delete("/trigger/api/themePlaylists", async (req, res) => {
const conn = await pool.getConnection();
const query = `DELETE FROM trigger_database.themePlaylists WHERE id = '${req.body.id}'`;
conn
.query(query)
.then((rows) => {
res.status(200).send({ status: "success" });
})
.catch((err) => {
res.status(500).send({ error: err });
});
conn.end();
});
app.get("/trigger/api/categories", async (req, res) => {
const conn = await pool.getConnection();
const query = "SELECT * from trigger_database.linkCategories;";
@@ -496,7 +547,7 @@ app.delete("/trigger/api/searchHistory", async (req, res) => {
res.status(500).send({ error: err });
});
conn.end();
})
});
// app is listening on port 5000
app.listen(5000, "0.0.0.0", () => {});