Updates to endpoint and table names
This commit is contained in:
@@ -17,13 +17,13 @@
|
|||||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `apps`
|
-- Table structure for table `applications`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `apps`;
|
DROP TABLE IF EXISTS `applications`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
/*!40101 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `apps` (
|
CREATE TABLE `applications` (
|
||||||
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
|
||||||
`name` varchar(50) NOT NULL,
|
`name` varchar(50) NOT NULL,
|
||||||
`url` varchar(50) NOT NULL,
|
`url` varchar(50) NOT NULL,
|
||||||
@@ -37,22 +37,22 @@ CREATE TABLE `apps` (
|
|||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `apps`
|
-- Dumping data for table `applications`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `apps` WRITE;
|
LOCK TABLES `applications` WRITE;
|
||||||
/*!40000 ALTER TABLE `apps` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `applications` DISABLE KEYS */;
|
||||||
/*!40000 ALTER TABLE `apps` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `applications` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `linkCategories`
|
-- Table structure for table `bookmarkCategories`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `linkCategories`;
|
DROP TABLE IF EXISTS `bookmarkCategories`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
/*!40101 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `linkCategories` (
|
CREATE TABLE `bookmarkCategories` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`categoryName` varchar(50) NOT NULL,
|
`categoryName` varchar(50) NOT NULL,
|
||||||
`categoryIndex` int(11) NOT NULL DEFAULT 0,
|
`categoryIndex` int(11) NOT NULL DEFAULT 0,
|
||||||
@@ -62,22 +62,22 @@ CREATE TABLE `linkCategories` (
|
|||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `linkCategories`
|
-- Dumping data for table `bookmarkCategories`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `linkCategories` WRITE;
|
LOCK TABLES `bookmarkCategories` WRITE;
|
||||||
/*!40000 ALTER TABLE `linkCategories` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `bookmarkCategories` DISABLE KEYS */;
|
||||||
/*!40000 ALTER TABLE `linkCategories` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `bookmarkCategories` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `links`
|
-- Table structure for table `bookmarks`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `links`;
|
DROP TABLE IF EXISTS `bookmarks`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
/*!40101 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `links` (
|
CREATE TABLE `bookmarks` (
|
||||||
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
|
||||||
`name` varchar(50) NOT NULL,
|
`name` varchar(50) NOT NULL,
|
||||||
`url` varchar(250) NOT NULL,
|
`url` varchar(250) NOT NULL,
|
||||||
@@ -88,12 +88,12 @@ CREATE TABLE `links` (
|
|||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `links`
|
-- Dumping data for table `bookmarks`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `links` WRITE;
|
LOCK TABLES `bookmarks` WRITE;
|
||||||
/*!40000 ALTER TABLE `links` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `bookmarks` DISABLE KEYS */;
|
||||||
/*!40000 ALTER TABLE `links` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `bookmarks` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
338
server.cjs
338
server.cjs
@@ -26,6 +26,10 @@ const corsOptions = {
|
|||||||
app.use(cors(corsOptions));
|
app.use(cors(corsOptions));
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
// Personal Data //
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/personalData", async (req, res) => {
|
app.get("/trigger/api/personalData", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * FROM trigger_database.personalData;";
|
const query = "SELECT * FROM trigger_database.personalData;";
|
||||||
@@ -49,6 +53,10 @@ app.patch("/trigger/api/personalData", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
// Messages //
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/messages", async (req, res) => {
|
app.get("/trigger/api/messages", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * FROM trigger_database.messages;";
|
const query = "SELECT * FROM trigger_database.messages;";
|
||||||
@@ -58,6 +66,16 @@ app.get("/trigger/api/messages", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get("/trigger/api/displayedGreeting", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
const query =
|
||||||
|
"SELECT * FROM trigger_database.messages ORDER BY RAND() LIMIT 1;";
|
||||||
|
conn.query(query).then((rows) => {
|
||||||
|
res.status(200).send(rows);
|
||||||
|
});
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/messages", async (req, res) => {
|
app.post("/trigger/api/messages", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.messages (message) VALUES (${escapeString(req.body.message)});`;
|
const query = `INSERT INTO trigger_database.messages (message) VALUES (${escapeString(req.body.message)});`;
|
||||||
@@ -100,7 +118,11 @@ app.delete("/trigger/api/messages", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/apps", async (req, res) => {
|
//////////////////////////////////////////////
|
||||||
|
// Application Data //
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
app.get("/trigger/api/applications", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * FROM trigger_database.apps;";
|
const query = "SELECT * FROM trigger_database.apps;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -109,7 +131,16 @@ app.get("/trigger/api/apps", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/apps", async (req, res) => {
|
app.get("/trigger/api/enabledApplications", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
const query = "SELECT * FROM trigger_database.apps WHERE enabled = 1;";
|
||||||
|
conn.query(query).then((rows) => {
|
||||||
|
res.status(200).send(rows);
|
||||||
|
});
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.post("/trigger/api/applications", 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, enabled, \`index\`) VALUES (${escapeString(req.body.name)}, ${escapeString(req.body.url)}, ${escapeString(req.body.icon)}, ${escapeString(req.body.baseUrl)}, ${escapeString(req.body.filterName)}, ${req.body.enabled}, ${req.body.index});`;
|
const query = `INSERT INTO trigger_database.apps (name, url, icon, baseUrl, filterName, enabled, \`index\`) VALUES (${escapeString(req.body.name)}, ${escapeString(req.body.url)}, ${escapeString(req.body.icon)}, ${escapeString(req.body.baseUrl)}, ${escapeString(req.body.filterName)}, ${req.body.enabled}, ${req.body.index});`;
|
||||||
conn
|
conn
|
||||||
@@ -123,7 +154,7 @@ app.post("/trigger/api/apps", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/apps", async (req, res) => {
|
app.patch("/trigger/api/applications", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.apps SET name = ${escapeString(req.body.name)}, url = ${escapeString(req.body.url)}, icon = ${escapeString(req.body.icon)}, baseUrl = ${escapeString(req.body.baseUrl)}, filterName = ${escapeString(req.body.filterName)}, enabled = ${req.body.enabled} WHERE id = ${req.body.id};`;
|
const query = `UPDATE trigger_database.apps SET name = ${escapeString(req.body.name)}, url = ${escapeString(req.body.url)}, icon = ${escapeString(req.body.icon)}, baseUrl = ${escapeString(req.body.baseUrl)}, filterName = ${escapeString(req.body.filterName)}, enabled = ${req.body.enabled} WHERE id = ${req.body.id};`;
|
||||||
conn
|
conn
|
||||||
@@ -137,7 +168,7 @@ app.patch("/trigger/api/apps", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/apps", async (req, res) => {
|
app.delete("/trigger/api/applications", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.apps WHERE id = ${req.body.id}`;
|
const query = `DELETE FROM trigger_database.apps WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -154,63 +185,45 @@ app.delete("/trigger/api/apps", async (req, res) => {
|
|||||||
app.get("/trigger/api/appCategories", async (req, res) => {
|
app.get("/trigger/api/appCategories", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query =
|
const query =
|
||||||
"SELECT filterName FROM trigger_database.apps UNION SELECT filterName FROM trigger_database.linkCategories;";
|
"SELECT filterName FROM trigger_database.apps UNION SELECT filterName FROM trigger_database.bookmarkCategories;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
res.status(200).send(rows);
|
res.status(200).send(rows);
|
||||||
});
|
});
|
||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/links", async (req, res) => {
|
app.patch("/trigger/api/applicationOrder", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * FROM trigger_database.links;";
|
|
||||||
conn.query(query).then((rows) => {
|
|
||||||
res.status(200).send(rows);
|
|
||||||
});
|
|
||||||
conn.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post("/trigger/api/links", async (req, res) => {
|
|
||||||
const conn = await pool.getConnection();
|
|
||||||
const query = `INSERT INTO trigger_database.links (name, url, category, \`index\`) VALUES (${escapeString(req.body.name)}, ${escapeString(req.body.url)}, ${escapeString(req.body.category)}, ${req.body.index});`;
|
|
||||||
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/links", async (req, res) => {
|
|
||||||
const conn = await pool.getConnection();
|
|
||||||
const query = `UPDATE trigger_database.links SET name = ${escapeString(req.body.name)}, url = ${escapeString(req.body.url)}, category = ${escapeString(req.body.category)} 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/links", async (req, res) => {
|
|
||||||
const conn = await pool.getConnection();
|
|
||||||
if (req.body.length > 1) {
|
|
||||||
req.body.map((link) => {
|
req.body.map((link) => {
|
||||||
conn
|
conn
|
||||||
.query("DELETE FROM trigger_database.links where id IN (?)", [link.id])
|
.query("UPDATE trigger_database.apps SET `index` = ? where id IN (?)", [
|
||||||
|
link.index,
|
||||||
|
link.id,
|
||||||
|
])
|
||||||
.then((rows) => {
|
.then((rows) => {
|
||||||
res.status(200);
|
res.status(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
res.send({ status: "success" });
|
res.send({ status: "success" });
|
||||||
} else {
|
conn.end();
|
||||||
const query = `DELETE FROM trigger_database.links WHERE id = ${req.body.id}`;
|
});
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
// Bookmark Data //
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
app.get("/trigger/api/bookmarks", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
const query = "SELECT * FROM trigger_database.bookmarks;";
|
||||||
|
conn.query(query).then((rows) => {
|
||||||
|
res.status(200).send(rows);
|
||||||
|
});
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.post("/trigger/api/bookmarks", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
const query = `INSERT INTO trigger_database.bookmarks (name, url, category, \`index\`) VALUES (${escapeString(req.body.name)}, ${escapeString(req.body.url)}, ${escapeString(req.body.category)}, ${req.body.index});`;
|
||||||
conn
|
conn
|
||||||
.query(query)
|
.query(query)
|
||||||
.then((rows) => {
|
.then((rows) => {
|
||||||
@@ -219,10 +232,131 @@ app.delete("/trigger/api/links", async (req, res) => {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
res.status(500).send({ error: err });
|
res.status(500).send({ error: err });
|
||||||
});
|
});
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.patch("/trigger/api/bookmarks", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
const query = `UPDATE trigger_database.bookmarks SET name = ${escapeString(req.body.name)}, url = ${escapeString(req.body.url)}, category = ${escapeString(req.body.category)} 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/bookmarks", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
if (req.body.length > 1) {
|
||||||
|
req.body.map((link) => {
|
||||||
|
conn
|
||||||
|
.query("DELETE FROM trigger_database.bookmarks where id IN (?)", [
|
||||||
|
link.id,
|
||||||
|
])
|
||||||
|
.then(() => {
|
||||||
|
res.status(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
res.send({ status: "success" });
|
||||||
|
} else {
|
||||||
|
const query = `DELETE FROM trigger_database.bookmarks WHERE id = ${req.body.id}`;
|
||||||
|
conn
|
||||||
|
.query(query)
|
||||||
|
.then(() => {
|
||||||
|
res.status(200).send({ status: "success" });
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
res.status(500).send({ error: err });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.patch("/trigger/api/bookmarkOrder", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
req.body.map((link) => {
|
||||||
|
conn
|
||||||
|
.query(
|
||||||
|
"UPDATE trigger_database.bookmarks SET `index` = ? where id IN (?)",
|
||||||
|
[link.index, link.id],
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
res.status(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
res.send({ status: "success" });
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get("/trigger/api/bookmarkCategories", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
const query = "SELECT * from trigger_database.bookmarkCategories;";
|
||||||
|
conn.query(query).then((rows) => {
|
||||||
|
res.status(200).send(rows);
|
||||||
|
});
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.post("/trigger/api/bookmarkCategories", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
const query = `INSERT INTO trigger_database.bookmarkCategories (categoryName, categoryIndex, filterName) VALUES (${escapeString(req.body.categoryName)},${req.body.categoryIndex || 0},${escapeString(req.body.filterName)})`;
|
||||||
|
conn.query(query).then((rows) => {
|
||||||
|
res.status(200).send({ status: "success" });
|
||||||
|
});
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.patch("/trigger/api/bookmarkCategories", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
const query = `UPDATE trigger_database.bookmarkCategories SET categoryName = ${escapeString(req.body.categoryName)}, filterName = ${escapeString(req.body.filterName)} 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/bookmarkCategories", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
const query = `DELETE FROM trigger_database.bookmarkCategories 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.patch("/trigger/api/bookmarkCategoryOrder", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
req.body.map((category) => {
|
||||||
|
conn
|
||||||
|
.query(
|
||||||
|
"UPDATE trigger_database.bookmarkCategories SET categoryIndex = ? where id IN (?)",
|
||||||
|
[category.index, category.id],
|
||||||
|
)
|
||||||
|
.then((rows) => {
|
||||||
|
res.status(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
res.send({ status: "success" });
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
// Provider Data //
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/providers", async (req, res) => {
|
app.get("/trigger/api/providers", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * FROM trigger_database.providers;";
|
const query = "SELECT * FROM trigger_database.providers;";
|
||||||
@@ -274,6 +408,10 @@ app.delete("/trigger/api/providers", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
// Theming //
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/themes", async (req, res) => {
|
app.get("/trigger/api/themes", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * FROM trigger_database.themes;";
|
const query = "SELECT * FROM trigger_database.themes;";
|
||||||
@@ -325,12 +463,6 @@ app.delete("/trigger/api/themes", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/backgrounds", async (req, res) => {
|
|
||||||
fs.readdir("../TriggerFrontend/dist/backgrounds", (err, files) => {
|
|
||||||
res.status(200).send(files);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get("/trigger/api/themePlaylists", async (req, res) => {
|
app.get("/trigger/api/themePlaylists", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * FROM trigger_database.themePlaylists;";
|
const query = "SELECT * FROM trigger_database.themePlaylists;";
|
||||||
@@ -382,99 +514,15 @@ app.delete("/trigger/api/themePlaylists", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/categories", async (req, res) => {
|
app.get("/trigger/api/backgrounds", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
fs.readdir("../TriggerFrontend/dist/backgrounds", (err, files) => {
|
||||||
const query = "SELECT * from trigger_database.linkCategories;";
|
res.status(200).send(files);
|
||||||
conn.query(query).then((rows) => {
|
|
||||||
res.status(200).send(rows);
|
|
||||||
});
|
});
|
||||||
conn.end();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/categories", async (req, res) => {
|
//////////////////////////////////////////////
|
||||||
const conn = await pool.getConnection();
|
// Wake on LAN Clients //
|
||||||
const query = `INSERT INTO trigger_database.linkCategories (categoryName, categoryIndex, filterName) VALUES (${escapeString(req.body.categoryName)},${req.body.categoryIndex || 0},${escapeString(req.body.filterName)})`;
|
//////////////////////////////////////////////
|
||||||
conn.query(query).then((rows) => {
|
|
||||||
res.status(200).send({ status: "success" });
|
|
||||||
});
|
|
||||||
conn.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
app.patch("/trigger/api/categories", async (req, res) => {
|
|
||||||
const conn = await pool.getConnection();
|
|
||||||
const query = `UPDATE trigger_database.linkCategories SET categoryName = ${escapeString(req.body.categoryName)}, filterName = ${escapeString(req.body.filterName)} 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/categories", async (req, res) => {
|
|
||||||
const conn = await pool.getConnection();
|
|
||||||
const query = `DELETE FROM trigger_database.linkCategories 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.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) => {
|
|
||||||
const conn = await pool.getConnection();
|
|
||||||
req.body.map((category) => {
|
|
||||||
conn
|
|
||||||
.query(
|
|
||||||
"UPDATE trigger_database.linkCategories SET categoryIndex = ? where id IN (?)",
|
|
||||||
[category.index, category.id],
|
|
||||||
)
|
|
||||||
.then((rows) => {
|
|
||||||
res.status(200);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
res.send({ status: "success" });
|
|
||||||
conn.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
app.patch("/trigger/api/linkOrder", async (req, res) => {
|
|
||||||
const conn = await pool.getConnection();
|
|
||||||
req.body.map((link) => {
|
|
||||||
conn
|
|
||||||
.query("UPDATE trigger_database.links SET `index` = ? where id IN (?)", [
|
|
||||||
link.index,
|
|
||||||
link.id,
|
|
||||||
])
|
|
||||||
.then((rows) => {
|
|
||||||
res.status(200);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
res.send({ status: "success" });
|
|
||||||
conn.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get("/trigger/api/wolClients", async (req, res) => {
|
app.get("/trigger/api/wolClients", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
@@ -535,6 +583,10 @@ app.post("/trigger/api/wakeClient", async (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
// Search //
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/searchHistory", async (req, res) => {
|
app.get("/trigger/api/searchHistory", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query =
|
const query =
|
||||||
|
|||||||
Reference in New Issue
Block a user