Updates to defaults
This commit is contained in:
@@ -2,4 +2,5 @@ DB_HOST='127.0.0.1'
|
|||||||
DB_USER='triggeradmin'
|
DB_USER='triggeradmin'
|
||||||
DB_PASS='trigger'
|
DB_PASS='trigger'
|
||||||
DB_PORT='3306'
|
DB_PORT='3306'
|
||||||
API_PORT='5000'
|
API_PORT='5000'
|
||||||
|
API_URI='trigger'
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
/*M!999999\- enable the sandbox mode */
|
/*M!999999\- enable the sandbox mode */
|
||||||
-- MariaDB dump 10.19 Distrib 10.11.13-MariaDB, for debian-linux-gnu (x86_64)
|
-- MariaDB dump 10.19-11.8.3-MariaDB, for debian-linux-gnu (x86_64)
|
||||||
--
|
--
|
||||||
-- Host: localhost Database: trigger_database
|
-- Host: localhost Database: trigger_database
|
||||||
-- ------------------------------------------------------
|
-- ------------------------------------------------------
|
||||||
-- Server version 10.11.13-MariaDB-0ubuntu0.24.04.1
|
-- Server version 11.8.3-MariaDB-1build1 from Ubuntu
|
||||||
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
/*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `applications`
|
-- Table structure for table `applications`
|
||||||
@@ -49,6 +49,7 @@ CREATE TABLE `bookmarkCategories` (
|
|||||||
`categoryName` varchar(50) NOT NULL,
|
`categoryName` varchar(50) NOT NULL,
|
||||||
`categoryIndex` int(11) NOT NULL DEFAULT 0,
|
`categoryIndex` int(11) NOT NULL DEFAULT 0,
|
||||||
`filterName` varchar(50) NOT NULL DEFAULT 'Default',
|
`filterName` varchar(50) NOT NULL DEFAULT 'Default',
|
||||||
|
`enabled` tinyint(4) NOT NULL DEFAULT 1,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `bookmarkCategories_unique` (`categoryName`)
|
UNIQUE KEY `bookmarkCategories_unique` (`categoryName`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
||||||
@@ -72,6 +73,23 @@ CREATE TABLE `bookmarks` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `guacamoleClients`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `guacamoleClients`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8mb4 */;
|
||||||
|
CREATE TABLE `guacamoleClients` (
|
||||||
|
`id` tinyint(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`clientName` varchar(100) NOT NULL,
|
||||||
|
`clientIdentifier` varchar(100) NOT NULL,
|
||||||
|
`enabled` tinyint(1) NOT NULL DEFAULT 1,
|
||||||
|
`type` varchar(20) NOT NULL DEFAULT 'SSH',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `messages`
|
-- Table structure for table `messages`
|
||||||
--
|
--
|
||||||
@@ -98,7 +116,12 @@ CREATE TABLE `personalData` (
|
|||||||
`firstName` varchar(50) NOT NULL DEFAULT 'First',
|
`firstName` varchar(50) NOT NULL DEFAULT 'First',
|
||||||
`lastName` varchar(50) NOT NULL DEFAULT 'Last',
|
`lastName` varchar(50) NOT NULL DEFAULT 'Last',
|
||||||
`email` varchar(50) NOT NULL DEFAULT 'triggerUser@default.com',
|
`email` varchar(50) NOT NULL DEFAULT 'triggerUser@default.com',
|
||||||
`physicalAddress` varchar(255) NOT NULL
|
`physicalAddress` varchar(255) NOT NULL,
|
||||||
|
`enableWol` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`enableGuacamole` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`guacamoleHost` varchar(255) DEFAULT NULL,
|
||||||
|
`nickname` varchar(100) DEFAULT NULL,
|
||||||
|
`defaultFont` varchar(255) NOT NULL DEFAULT 'Jost'
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
@@ -109,7 +132,7 @@ CREATE TABLE `personalData` (
|
|||||||
LOCK TABLES `personalData` WRITE;
|
LOCK TABLES `personalData` WRITE;
|
||||||
/*!40000 ALTER TABLE `personalData` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `personalData` DISABLE KEYS */;
|
||||||
INSERT INTO `personalData` VALUES
|
INSERT INTO `personalData` VALUES
|
||||||
('First','Last','triggeruser@trigger.com','1600 Pennsylvania Avenue NW, Washington, DC 20500');
|
('First','Last','triggeruser@trigger.com','1600 Pennsylvania Avenue NW, Washington, DC 20500', 0, 0, NULL, NULL, 'Jost');
|
||||||
/*!40000 ALTER TABLE `personalData` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `personalData` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
@@ -125,6 +148,9 @@ CREATE TABLE `providers` (
|
|||||||
`name` varchar(50) NOT NULL,
|
`name` varchar(50) NOT NULL,
|
||||||
`url` varchar(250) NOT NULL,
|
`url` varchar(250) NOT NULL,
|
||||||
`prefix` varchar(50) NOT NULL,
|
`prefix` varchar(50) NOT NULL,
|
||||||
|
`default` tinyint(4) NOT NULL DEFAULT 0,
|
||||||
|
`enabled` tinyint(1) DEFAULT 1,
|
||||||
|
`icon` varchar(50) NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `providers_unique` (`prefix`)
|
UNIQUE KEY `providers_unique` (`prefix`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
||||||
@@ -194,6 +220,7 @@ CREATE TABLE `themes` (
|
|||||||
`randomEnabled` tinyint(1) NOT NULL DEFAULT 0,
|
`randomEnabled` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
`textShadowsEnabled` tinyint(4) NOT NULL DEFAULT 0,
|
`textShadowsEnabled` tinyint(4) NOT NULL DEFAULT 0,
|
||||||
`appShadowsEnabled` tinyint(4) NOT NULL DEFAULT 0,
|
`appShadowsEnabled` tinyint(4) NOT NULL DEFAULT 0,
|
||||||
|
`themeFont` varchar(255) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `themes_unique` (`name`)
|
UNIQUE KEY `themes_unique` (`name`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
|
||||||
@@ -206,7 +233,7 @@ CREATE TABLE `themes` (
|
|||||||
LOCK TABLES `themes` WRITE;
|
LOCK TABLES `themes` WRITE;
|
||||||
/*!40000 ALTER TABLE `themes` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `themes` DISABLE KEYS */;
|
||||||
INSERT INTO `themes` VALUES
|
INSERT INTO `themes` VALUES
|
||||||
(0000000001,'blackboard','none','#1a1a1a','#FFFDEA20','#FFFDEA','#5c5c5c','#5c5c5c',1,0,1);
|
(0000000001,'blackboard','none','#1a1a1a','#FFFDEA20','#FFFDEA','#5c5c5c','#5c5c5c',1,0,1,'Jost');
|
||||||
/*!40000 ALTER TABLE `themes` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `themes` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
@@ -236,6 +263,6 @@ CREATE TABLE `wolClients` (
|
|||||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;
|
||||||
|
|
||||||
-- Dump completed on 2025-07-21 16:54:41
|
-- Dump completed on 2026-02-02 10:30:35
|
||||||
|
|||||||
114
server.cjs
114
server.cjs
@@ -38,7 +38,7 @@ app.use(cors(corsOptions));
|
|||||||
app.use(bodyParser.json({ limit: "50mb" }));
|
app.use(bodyParser.json({ limit: "50mb" }));
|
||||||
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
|
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
|
||||||
app.use(
|
app.use(
|
||||||
"/trigger/api/backgroundImages",
|
`/${process.env.API_URI}/api/backgroundImages`,
|
||||||
express.static("../TriggerFrontend/backgrounds"),
|
express.static("../TriggerFrontend/backgrounds"),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ app.use(
|
|||||||
// Personal Data //
|
// Personal Data //
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/personalData", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/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;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -55,7 +55,7 @@ app.get("/trigger/api/personalData", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/guacamoleHost", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/guacamoleHost`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT guacamoleHost FROM trigger_database.personalData;";
|
const query = "SELECT guacamoleHost FROM trigger_database.personalData;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -64,7 +64,7 @@ app.get("/trigger/api/guacamoleHost", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get("/trigger/api/guacamoleEnabled", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/guacamoleEnabled`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT enableGuacamole FROM trigger_database.personalData;";
|
const query = "SELECT enableGuacamole FROM trigger_database.personalData;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -73,7 +73,7 @@ app.get("/trigger/api/guacamoleEnabled", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get("/trigger/api/wolEnabled", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/wolEnabled`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT enableWol FROM trigger_database.personalData;";
|
const query = "SELECT enableWol FROM trigger_database.personalData;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -82,7 +82,7 @@ app.get("/trigger/api/wolEnabled", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
})
|
})
|
||||||
|
|
||||||
app.patch("/trigger/api/personalData", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/personalData`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.personalData SET firstName = ${escapeString(req.body.firstName)}, lastName = ${escapeString(req.body.lastName)}, email = ${escapeString(req.body.email)}, physicalAddress = ${escapeString(req.body.physicalAddress)}, enableWol = ${req.body.enableWol}, enableGuacamole = ${req.body.enableGuacamole}, guacamoleHost = ${escapeString(req.body.guacamoleHost)}, nickname = ${escapeString(req.body.nickname)}, defaultFont = ${escapeString(req.body.defaultFont)};`;
|
const query = `UPDATE trigger_database.personalData SET firstName = ${escapeString(req.body.firstName)}, lastName = ${escapeString(req.body.lastName)}, email = ${escapeString(req.body.email)}, physicalAddress = ${escapeString(req.body.physicalAddress)}, enableWol = ${req.body.enableWol}, enableGuacamole = ${req.body.enableGuacamole}, guacamoleHost = ${escapeString(req.body.guacamoleHost)}, nickname = ${escapeString(req.body.nickname)}, defaultFont = ${escapeString(req.body.defaultFont)};`;
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ app.patch("/trigger/api/personalData", async (req, res) => {
|
|||||||
// Messages //
|
// Messages //
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/messages", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/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;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -110,7 +110,7 @@ app.get("/trigger/api/messages", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/displayedGreeting", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/displayedGreeting`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query =
|
const query =
|
||||||
"SELECT * FROM trigger_database.messages WHERE customGreeting = 1 ORDER BY RAND() LIMIT 1;";
|
"SELECT * FROM trigger_database.messages WHERE customGreeting = 1 ORDER BY RAND() LIMIT 1;";
|
||||||
@@ -120,7 +120,7 @@ app.get("/trigger/api/displayedGreeting", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/messages", async (req, res) => {
|
app.post(`/${process.env.API_URI}/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)});`;
|
||||||
conn
|
conn
|
||||||
@@ -134,7 +134,7 @@ app.post("/trigger/api/messages", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/messages", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/messages`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.messages SET message = ${escapeString(req.body.message)}, customGreeting = ${req.body.customGreeting} WHERE id = ${req.body.id};`;
|
const query = `UPDATE trigger_database.messages SET message = ${escapeString(req.body.message)}, customGreeting = ${req.body.customGreeting} WHERE id = ${req.body.id};`;
|
||||||
conn
|
conn
|
||||||
@@ -148,7 +148,7 @@ app.patch("/trigger/api/messages", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/messages", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/messages`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.messages WHERE id = ${req.body.id};`;
|
const query = `DELETE FROM trigger_database.messages WHERE id = ${req.body.id};`;
|
||||||
conn
|
conn
|
||||||
@@ -166,7 +166,7 @@ app.delete("/trigger/api/messages", async (req, res) => {
|
|||||||
// Application Data //
|
// Application Data //
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/applications", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/applications`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * FROM trigger_database.applications;";
|
const query = "SELECT * FROM trigger_database.applications;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -175,7 +175,7 @@ app.get("/trigger/api/applications", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/enabledApplications", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/enabledApplications`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query =
|
const query =
|
||||||
"SELECT * FROM trigger_database.applications WHERE enabled = 1;";
|
"SELECT * FROM trigger_database.applications WHERE enabled = 1;";
|
||||||
@@ -185,7 +185,7 @@ app.get("/trigger/api/enabledApplications", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/applications", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/applications`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.applications (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.applications (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
|
||||||
@@ -199,7 +199,7 @@ app.post("/trigger/api/applications", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/applications", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/applications`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.applications 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.applications 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
|
||||||
@@ -213,7 +213,7 @@ app.patch("/trigger/api/applications", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/applications", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/applications`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.applications WHERE id = ${req.body.id}`;
|
const query = `DELETE FROM trigger_database.applications WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -227,7 +227,7 @@ app.delete("/trigger/api/applications", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/appCategories", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/appCategories`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query =
|
const query =
|
||||||
"SELECT filterName FROM trigger_database.applications UNION SELECT filterName FROM trigger_database.bookmarkCategories;";
|
"SELECT filterName FROM trigger_database.applications UNION SELECT filterName FROM trigger_database.bookmarkCategories;";
|
||||||
@@ -237,7 +237,7 @@ app.get("/trigger/api/appCategories", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/applicationOrder", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/applicationOrder`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
req.body.map((link) => {
|
req.body.map((link) => {
|
||||||
conn
|
conn
|
||||||
@@ -257,7 +257,7 @@ app.patch("/trigger/api/applicationOrder", async (req, res) => {
|
|||||||
// Bookmark Data //
|
// Bookmark Data //
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/bookmarks", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/bookmarks`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * FROM trigger_database.bookmarks;";
|
const query = "SELECT * FROM trigger_database.bookmarks;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -266,7 +266,7 @@ app.get("/trigger/api/bookmarks", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/bookmarks", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/bookmarks`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.bookmarks (name, url, category, \`index\`, enabled) VALUES (${escapeString(req.body.name)}, ${escapeString(req.body.url)}, ${escapeString(req.body.category)}, ${req.body.index}, ${req.body.enabled});`;
|
const query = `INSERT INTO trigger_database.bookmarks (name, url, category, \`index\`, enabled) VALUES (${escapeString(req.body.name)}, ${escapeString(req.body.url)}, ${escapeString(req.body.category)}, ${req.body.index}, ${req.body.enabled});`;
|
||||||
conn
|
conn
|
||||||
@@ -280,7 +280,7 @@ app.post("/trigger/api/bookmarks", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/bookmarks", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/bookmarks`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
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)}, \`index\` = ${req.body.index}, enabled = ${req.body.enabled} WHERE id = ${req.body.id}`;
|
const query = `UPDATE trigger_database.bookmarks SET name = ${escapeString(req.body.name)}, url = ${escapeString(req.body.url)}, category = ${escapeString(req.body.category)}, \`index\` = ${req.body.index}, enabled = ${req.body.enabled} WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -294,7 +294,7 @@ app.patch("/trigger/api/bookmarks", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/bookmarks", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/bookmarks`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
if (req.body.length > 1) {
|
if (req.body.length > 1) {
|
||||||
req.body.map((link) => {
|
req.body.map((link) => {
|
||||||
@@ -321,7 +321,7 @@ app.delete("/trigger/api/bookmarks", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/bookmarkOrder", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/bookmarkOrder`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
req.body.map((link) => {
|
req.body.map((link) => {
|
||||||
conn
|
conn
|
||||||
@@ -337,7 +337,7 @@ app.patch("/trigger/api/bookmarkOrder", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/bookmarkCategories", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/bookmarkCategories`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * from trigger_database.bookmarkCategories;";
|
const query = "SELECT * from trigger_database.bookmarkCategories;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -346,7 +346,7 @@ app.get("/trigger/api/bookmarkCategories", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/bookmarkCategories", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/bookmarkCategories`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
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)})`;
|
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) => {
|
conn.query(query).then((_rows) => {
|
||||||
@@ -355,7 +355,7 @@ app.post("/trigger/api/bookmarkCategories", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/bookmarkCategories", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/bookmarkCategories`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.bookmarkCategories SET categoryName = ${escapeString(req.body.categoryName)}, filterName = ${escapeString(req.body.filterName)}, enabled = ${req.body.enabled} WHERE id = ${req.body.id};`;
|
const query = `UPDATE trigger_database.bookmarkCategories SET categoryName = ${escapeString(req.body.categoryName)}, filterName = ${escapeString(req.body.filterName)}, enabled = ${req.body.enabled} WHERE id = ${req.body.id};`;
|
||||||
conn
|
conn
|
||||||
@@ -369,7 +369,7 @@ app.patch("/trigger/api/bookmarkCategories", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/bookmarkCategories", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/bookmarkCategories`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.bookmarkCategories WHERE id = ${req.body.id}`;
|
const query = `DELETE FROM trigger_database.bookmarkCategories WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -383,7 +383,7 @@ app.delete("/trigger/api/bookmarkCategories", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/bookmarkCategoryOrder", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/bookmarkCategoryOrder`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
req.body.map((category) => {
|
req.body.map((category) => {
|
||||||
conn
|
conn
|
||||||
@@ -403,7 +403,7 @@ app.patch("/trigger/api/bookmarkCategoryOrder", async (req, res) => {
|
|||||||
// Provider Data //
|
// Provider Data //
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/providers", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/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;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -412,7 +412,7 @@ app.get("/trigger/api/providers", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/providers/default", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/providers/default`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `SELECT * FROM trigger_database.providers WHERE \`default\` = 1;`;
|
const query = `SELECT * FROM trigger_database.providers WHERE \`default\` = 1;`;
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -421,7 +421,7 @@ app.get("/trigger/api/providers/default", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/providers", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/providers`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
if (req.body.default === true || req.body.default === 1) {
|
if (req.body.default === true || req.body.default === 1) {
|
||||||
const query = `UPDATE trigger_database.providers SET \`default\` = 0;`;
|
const query = `UPDATE trigger_database.providers SET \`default\` = 0;`;
|
||||||
@@ -439,7 +439,7 @@ app.post("/trigger/api/providers", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/providers", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/providers`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
if (req.body.default === true || req.body.default === 1) {
|
if (req.body.default === true || req.body.default === 1) {
|
||||||
const query = `UPDATE trigger_database.providers SET \`default\` = 0;`;
|
const query = `UPDATE trigger_database.providers SET \`default\` = 0;`;
|
||||||
@@ -457,7 +457,7 @@ app.patch("/trigger/api/providers", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/providers", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/providers`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.providers WHERE id = ${req.body.id}`;
|
const query = `DELETE FROM trigger_database.providers WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -475,7 +475,7 @@ app.delete("/trigger/api/providers", async (req, res) => {
|
|||||||
// Theming //
|
// Theming //
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/themes", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/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;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -484,7 +484,7 @@ app.get("/trigger/api/themes", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/themes", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/themes`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.themes (name, backgroundImage, backgroundColor, searchColor, primaryColor, accentColor, borderColor, themeFont) VALUES (${escapeString(req.body.name)},${escapeString(req.body.backgroundImage)},${escapeString(req.body.backgroundColor)},${escapeString(req.body.searchColor)},${escapeString(req.body.primaryColor)},${escapeString(req.body.accentColor)},${escapeString(req.body.borderColor)},${escapeString(req.body.themeFont)})`;
|
const query = `INSERT INTO trigger_database.themes (name, backgroundImage, backgroundColor, searchColor, primaryColor, accentColor, borderColor, themeFont) VALUES (${escapeString(req.body.name)},${escapeString(req.body.backgroundImage)},${escapeString(req.body.backgroundColor)},${escapeString(req.body.searchColor)},${escapeString(req.body.primaryColor)},${escapeString(req.body.accentColor)},${escapeString(req.body.borderColor)},${escapeString(req.body.themeFont)})`;
|
||||||
conn
|
conn
|
||||||
@@ -498,7 +498,7 @@ app.post("/trigger/api/themes", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/themes", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/themes`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.themes SET name = ${escapeString(req.body.name)}, backgroundImage = ${escapeString(req.body.backgroundImage)}, backgroundColor = ${escapeString(req.body.backgroundColor)}, searchColor = ${escapeString(req.body.searchColor)}, primaryColor = ${escapeString(req.body.primaryColor)}, accentColor = ${escapeString(req.body.accentColor)}, borderColor = ${escapeString(req.body.borderColor)}, randomEnabled = ${req.body.randomEnabled ? 1 : 0}, textShadowsEnabled = ${req.body.textShadowsEnabled ? 1 : 0}, appShadowsEnabled = ${req.body.appShadowsEnabled ? 1 : 0}, themeFont = ${req.body.themeFont === null ? null : escapeString(req.body.themeFont)} WHERE id = ${req.body.id};`;
|
const query = `UPDATE trigger_database.themes SET name = ${escapeString(req.body.name)}, backgroundImage = ${escapeString(req.body.backgroundImage)}, backgroundColor = ${escapeString(req.body.backgroundColor)}, searchColor = ${escapeString(req.body.searchColor)}, primaryColor = ${escapeString(req.body.primaryColor)}, accentColor = ${escapeString(req.body.accentColor)}, borderColor = ${escapeString(req.body.borderColor)}, randomEnabled = ${req.body.randomEnabled ? 1 : 0}, textShadowsEnabled = ${req.body.textShadowsEnabled ? 1 : 0}, appShadowsEnabled = ${req.body.appShadowsEnabled ? 1 : 0}, themeFont = ${req.body.themeFont === null ? null : escapeString(req.body.themeFont)} WHERE id = ${req.body.id};`;
|
||||||
conn
|
conn
|
||||||
@@ -512,7 +512,7 @@ app.patch("/trigger/api/themes", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/themes", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/themes`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.themes WHERE id = ${req.body.id}`;
|
const query = `DELETE FROM trigger_database.themes WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -526,7 +526,7 @@ app.delete("/trigger/api/themes", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/themePlaylists", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/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;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -535,7 +535,7 @@ app.get("/trigger/api/themePlaylists", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/themePlaylists", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/themePlaylists`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.themePlaylists (name, themeList) VALUES (${escapeString(req.body.name)},${escapeString(req.body.themeList)});`;
|
const query = `INSERT INTO trigger_database.themePlaylists (name, themeList) VALUES (${escapeString(req.body.name)},${escapeString(req.body.themeList)});`;
|
||||||
conn
|
conn
|
||||||
@@ -549,7 +549,7 @@ app.post("/trigger/api/themePlaylists", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/themePlaylists", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/themePlaylists`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.themePlaylists SET name = ${escapeString(req.body.name)}, themeList = ${escapeString(req.body.themeList)} WHERE id = ${req.body.id};`;
|
const query = `UPDATE trigger_database.themePlaylists SET name = ${escapeString(req.body.name)}, themeList = ${escapeString(req.body.themeList)} WHERE id = ${req.body.id};`;
|
||||||
conn
|
conn
|
||||||
@@ -563,7 +563,7 @@ app.patch("/trigger/api/themePlaylists", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/themePlaylists", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/themePlaylists`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.themePlaylists WHERE id = ${req.body.id}`;
|
const query = `DELETE FROM trigger_database.themePlaylists WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -577,7 +577,7 @@ app.delete("/trigger/api/themePlaylists", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/backgrounds", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/backgrounds`, async (_req, res) => {
|
||||||
fs.readdir(
|
fs.readdir(
|
||||||
"../TriggerFrontend/backgrounds",
|
"../TriggerFrontend/backgrounds",
|
||||||
{ withFileTypes: true },
|
{ withFileTypes: true },
|
||||||
@@ -590,7 +590,7 @@ app.get("/trigger/api/backgrounds", async (_req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.post(
|
app.post(
|
||||||
"/trigger/api/backgrounds",
|
`/${process.env.API_URI}/api/backgrounds`,
|
||||||
uploads.single("background"),
|
uploads.single("background"),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const image = req.file.path;
|
const image = req.file.path;
|
||||||
@@ -603,7 +603,7 @@ app.post(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
app.patch("/trigger/api/backgrounds", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/backgrounds`, async (req, res) => {
|
||||||
fs.rename(
|
fs.rename(
|
||||||
`../TriggerFrontend/backgrounds/${req.body.fileName}`,
|
`../TriggerFrontend/backgrounds/${req.body.fileName}`,
|
||||||
`../TriggerFrontend/backgrounds/${req.body.newFileName}`,
|
`../TriggerFrontend/backgrounds/${req.body.newFileName}`,
|
||||||
@@ -631,7 +631,7 @@ app.patch("/trigger/api/backgrounds", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/backgrounds", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/backgrounds`, async (req, res) => {
|
||||||
fs.rm(`../TriggerFrontend/backgrounds/${req.body.fileName}`, (_err) => {
|
fs.rm(`../TriggerFrontend/backgrounds/${req.body.fileName}`, (_err) => {
|
||||||
if (_err) throw _err;
|
if (_err) throw _err;
|
||||||
});
|
});
|
||||||
@@ -658,7 +658,7 @@ app.delete("/trigger/api/backgrounds", async (req, res) => {
|
|||||||
// Wake on LAN Clients //
|
// Wake on LAN Clients //
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/wolClients", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/wolClients`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * from trigger_database.wolClients;";
|
const query = "SELECT * from trigger_database.wolClients;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -667,7 +667,7 @@ app.get("/trigger/api/wolClients", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/wolClients", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/wolClients`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.wolClients (hostname, macAddress) VALUES (${escapeString(req.body.hostname)}, ${escapeString(req.body.macAddress)})`;
|
const query = `INSERT INTO trigger_database.wolClients (hostname, macAddress) VALUES (${escapeString(req.body.hostname)}, ${escapeString(req.body.macAddress)})`;
|
||||||
conn
|
conn
|
||||||
@@ -681,7 +681,7 @@ app.post("/trigger/api/wolClients", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/wolClients", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/wolClients`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.wolClients SET hostname = ${escapeString(req.body.hostname)}, macAddress = ${escapeString(req.body.macAddress)} WHERE id = ${req.body.id}`;
|
const query = `UPDATE trigger_database.wolClients SET hostname = ${escapeString(req.body.hostname)}, macAddress = ${escapeString(req.body.macAddress)} WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -695,7 +695,7 @@ app.patch("/trigger/api/wolClients", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/wolClients", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/wolClients`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.wolClients WHERE id = ${req.body.id}`;
|
const query = `DELETE FROM trigger_database.wolClients WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -709,7 +709,7 @@ app.delete("/trigger/api/wolClients", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/wakeClient", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/wakeClient`, async (req, res) => {
|
||||||
wol.wake(req.body.macAddress, () => {
|
wol.wake(req.body.macAddress, () => {
|
||||||
res.status(200).send({ status: "success" });
|
res.status(200).send({ status: "success" });
|
||||||
});
|
});
|
||||||
@@ -719,7 +719,7 @@ app.post("/trigger/api/wakeClient", async (req, res) => {
|
|||||||
// Guacamole Clients //
|
// Guacamole Clients //
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/guacamoleClients", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/guacamoleClients`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * from trigger_database.guacamoleClients;";
|
const query = "SELECT * from trigger_database.guacamoleClients;";
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
@@ -728,7 +728,7 @@ app.get("/trigger/api/guacamoleClients", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/guacamoleClients", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/guacamoleClients`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.guacamoleClients (clientName, clientIdentifier, enabled, type) VALUES (${escapeString(req.body.clientName)}, ${escapeString(req.body.clientIdentifier)}, ${req.body.enabled}, ${escapeString(req.body.type)})`;
|
const query = `INSERT INTO trigger_database.guacamoleClients (clientName, clientIdentifier, enabled, type) VALUES (${escapeString(req.body.clientName)}, ${escapeString(req.body.clientIdentifier)}, ${req.body.enabled}, ${escapeString(req.body.type)})`;
|
||||||
conn
|
conn
|
||||||
@@ -742,7 +742,7 @@ app.post("/trigger/api/guacamoleClients", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/trigger/api/guacamoleClients", async (req, res) => {
|
app.patch(`/${process.env.API_URI}/api/guacamoleClients`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `UPDATE trigger_database.guacamoleClients SET clientName = ${escapeString(req.body.clientName)}, clientIdentifier = ${escapeString(req.body.clientIdentifier)} , enabled = ${req.body.enabled}, type = ${escapeString(req.body.type)} WHERE id = ${req.body.id}`;
|
const query = `UPDATE trigger_database.guacamoleClients SET clientName = ${escapeString(req.body.clientName)}, clientIdentifier = ${escapeString(req.body.clientIdentifier)} , enabled = ${req.body.enabled}, type = ${escapeString(req.body.type)} WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -756,7 +756,7 @@ app.patch("/trigger/api/guacamoleClients", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/guacamoleClients", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/guacamoleClients`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.guacamoleClients WHERE id = ${req.body.id}`;
|
const query = `DELETE FROM trigger_database.guacamoleClients WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
@@ -774,7 +774,7 @@ app.delete("/trigger/api/guacamoleClients", async (req, res) => {
|
|||||||
// Search //
|
// Search //
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
app.get("/trigger/api/searchHistory", async (_req, res) => {
|
app.get(`/${process.env.API_URI}/api/searchHistory`, async (_req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query =
|
const query =
|
||||||
"SELECT * FROM trigger_database.searchHistory ORDER BY dateTimeStamp DESC;";
|
"SELECT * FROM trigger_database.searchHistory ORDER BY dateTimeStamp DESC;";
|
||||||
@@ -784,7 +784,7 @@ app.get("/trigger/api/searchHistory", async (_req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/trigger/api/searchHistory", async (req, res) => {
|
app.post(`/${process.env.API_URI}/api/searchHistory`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.searchHistory (prefix, provider, searchTerm) VALUES (${escapeString(req.body.prefix)}, ${escapeString(req.body.provider)}, ${escapeString(req.body.searchTerm)})`;
|
const query = `INSERT INTO trigger_database.searchHistory (prefix, provider, searchTerm) VALUES (${escapeString(req.body.prefix)}, ${escapeString(req.body.provider)}, ${escapeString(req.body.searchTerm)})`;
|
||||||
conn
|
conn
|
||||||
@@ -798,7 +798,7 @@ app.post("/trigger/api/searchHistory", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/trigger/api/searchHistory", async (req, res) => {
|
app.delete(`/${process.env.API_URI}/api/searchHistory`, async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `DELETE FROM trigger_database.searchHistory WHERE id = ${req.body.id}`;
|
const query = `DELETE FROM trigger_database.searchHistory WHERE id = ${req.body.id}`;
|
||||||
conn
|
conn
|
||||||
|
|||||||
Reference in New Issue
Block a user