Linted
This commit is contained in:
36
server.cjs
36
server.cjs
@@ -407,17 +407,9 @@ app.get("/trigger/api/categories", async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/categories", async (req, res) => {
|
app.post("/trigger/api/categories", async (req, res) => {
|
||||||
let conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
let query = "SELECT * from trigger_database.linkCategories;";
|
const query = `INSERT INTO trigger_database.linkCategories (categoryName, categoryIndex, filterName) VALUES ('${sqlEscape(req.body.categoryName)}','${req.body.categoryIndex || 0}','${sqlEscape(req.body.filterName)}')`;
|
||||||
let categoryIndex;
|
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
categoryIndex = rows.length;
|
|
||||||
});
|
|
||||||
conn.end();
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
query = `INSERT INTO trigger_database.linkCategories (categoryName, categoryIndex, filterName) VALUES ('${sqlEscape(req.body.categoryName)}','${req.body.categoryIndex || 0}','${sqlEscape(req.body.filterName)}')`;
|
|
||||||
conn.query(query).then((rows) => {
|
|
||||||
categoryIndex = rows.length;
|
|
||||||
res.status(200).send({ status: "success" });
|
res.status(200).send({ status: "success" });
|
||||||
});
|
});
|
||||||
conn.end();
|
conn.end();
|
||||||
@@ -455,28 +447,32 @@ app.patch("/trigger/api/categoryOrder", async (req, res) => {
|
|||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
req.body.map((category) => {
|
req.body.map((category) => {
|
||||||
conn
|
conn
|
||||||
.query("UPDATE trigger_database.linkCategories SET categoryIndex = ? where id IN (?)", [category.index, category.id])
|
.query(
|
||||||
.then((rows) => {
|
"UPDATE trigger_database.linkCategories SET categoryIndex = ? where id IN (?)",
|
||||||
res.status(200);
|
[category.index, category.id],
|
||||||
});
|
)
|
||||||
|
.then((rows) => {
|
||||||
|
res.status(200);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
res.send({ status: "success" });
|
res.send({ status: "success" });
|
||||||
conn.end();
|
conn.end();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/linkOrder", async (req, res) => {
|
app.patch("/trigger/api/linkOrder", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
req.body.map((link) => {
|
req.body.map((link) => {
|
||||||
conn
|
conn
|
||||||
.query("UPDATE trigger_database.links SET \`index\` = ? where id IN (?)", [link.index, link.id])
|
.query("UPDATE trigger_database.links SET `index` = ? where id IN (?)", [
|
||||||
.then((rows) => {
|
link.index,
|
||||||
res.status(200);
|
link.id,
|
||||||
});
|
])
|
||||||
|
.then((rows) => {
|
||||||
|
res.status(200);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
res.send({ status: "success" });
|
res.send({ status: "success" });
|
||||||
conn.end();
|
conn.end();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/wolClients", async (req, res) => {
|
app.get("/trigger/api/wolClients", async (req, res) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user