New endpoints
This commit is contained in:
20
server.cjs
20
server.cjs
@@ -137,7 +137,7 @@ app.get("/trigger/api/apps", async (req, res) => {
|
|||||||
|
|
||||||
app.post("/trigger/api/apps", async (req, res) => {
|
app.post("/trigger/api/apps", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.apps (name, url, icon, baseUrl, filterName) VALUES ('${sqlEscape(req.body.name)}', '${sqlEscape(req.body.url)}', '${sqlEscape(req.body.icon)}', '${sqlEscape(req.body.baseUrl)}', '${sqlEscape(req.body.filterName)}');`;
|
const query = `INSERT INTO trigger_database.apps (name, url, icon, baseUrl, filterName, enabled) VALUES ('${sqlEscape(req.body.name)}', '${sqlEscape(req.body.url)}', '${sqlEscape(req.body.icon)}', '${sqlEscape(req.body.baseUrl)}', '${sqlEscape(req.body.filterName)}', ${req.body.enabled});`;
|
||||||
conn
|
conn
|
||||||
.query(query)
|
.query(query)
|
||||||
.then((rows) => {
|
.then((rows) => {
|
||||||
@@ -151,7 +151,7 @@ app.post("/trigger/api/apps", async (req, res) => {
|
|||||||
|
|
||||||
app.patch("/trigger/api/apps", async (req, res) => {
|
app.patch("/trigger/api/apps", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.apps SET name = '${sqlEscape(req.body.name)}', url = '${sqlEscape(req.body.url)}', icon = '${sqlEscape(req.body.icon)}', baseUrl = '${sqlEscape(req.body.baseUrl)}', filterName = '${sqlEscape(req.body.filterName)}' WHERE id = '${req.body.id}';`;
|
const query = `UPDATE trigger_database.apps SET name = '${sqlEscape(req.body.name)}', url = '${sqlEscape(req.body.url)}', icon = '${sqlEscape(req.body.icon)}', baseUrl = '${sqlEscape(req.body.baseUrl)}', filterName = '${sqlEscape(req.body.filterName)}', enabled = ${req.body.enabled} WHERE id = '${req.body.id}';`;
|
||||||
conn
|
conn
|
||||||
.query(query)
|
.query(query)
|
||||||
.then((rows) => {
|
.then((rows) => {
|
||||||
@@ -443,6 +443,22 @@ app.delete("/trigger/api/categories", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.patch("/trigger/api/applicationOrder", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
req.body.map((link) => {
|
||||||
|
conn
|
||||||
|
.query("UPDATE trigger_database.apps SET `index` = ? where id IN (?)", [
|
||||||
|
link.index,
|
||||||
|
link.id,
|
||||||
|
])
|
||||||
|
.then((rows) => {
|
||||||
|
res.status(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
res.send({ status: "success" });
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/categoryOrder", async (req, res) => {
|
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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user