From ed133380fbc74ef3b6930d1ea125205ffe2e36fc Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Wed, 20 Oct 2021 17:54:54 +0200 Subject: Add plugin & css support, add styling to differentiate from discord.com --- api/src/middlewares/TestClient.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'api/src/middlewares') diff --git a/api/src/middlewares/TestClient.ts b/api/src/middlewares/TestClient.ts index b718bdab..7d981f0c 100644 --- a/api/src/middlewares/TestClient.ts +++ b/api/src/middlewares/TestClient.ts @@ -24,8 +24,20 @@ export default function TestClient(app: Application) { html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: \`${GATEWAY_ENDPOINT}\`,`); } - app.use("/assets", express.static(path.join(__dirname, "..", "..", "assets"))); + //plugins + var files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "plugins")); + var plugins = ""; + files.forEach(x =>{if(x.endsWith(".js")) plugins += `\n`; }); + html = html.replaceAll("", plugins); + //preload plugins + files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "preload-plugins")); + plugins = ""; + files.forEach(x =>{if(x.endsWith(".js")) plugins += `\n`; }); + html = html.replaceAll("", plugins); + + app.use("/assets", express.static(path.join(__dirname, "..", "..", "assets"))); + app.get("/assets/:file", async (req: Request, res: Response) => { delete req.headers.host; var response: FetchResponse; -- cgit 1.4.1 From a61bba7e27a0d0081d176aac6900c09f7d695428 Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Thu, 11 Nov 2021 22:17:21 +0100 Subject: Inline plugin support --- api/client_test/index.html | 6 +++--- api/package-lock.json | 2 ++ api/src/middlewares/TestClient.ts | 11 ++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'api/src/middlewares') diff --git a/api/client_test/index.html b/api/client_test/index.html index b19d5f0d..0b3a775a 100644 --- a/api/client_test/index.html +++ b/api/client_test/index.html @@ -4,9 +4,9 @@ Discord Test Client - - - + + + diff --git a/api/package-lock.json b/api/package-lock.json index e8ebd5bf..a4ad6b2b 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -84,6 +84,7 @@ "pg": "^8.7.1", "proxy-agent": "^5.0.0", "reflect-metadata": "^0.1.13", + "sqlite3": "^5.0.2", "typeorm": "^0.2.38", "typescript": "^4.4.2", "typescript-json-schema": "^0.50.1" @@ -16162,6 +16163,7 @@ "pg": "^8.7.1", "proxy-agent": "^5.0.0", "reflect-metadata": "^0.1.13", + "sqlite3": "^5.0.2", "ts-node": "^10.2.1", "typeorm": "^0.2.38", "typescript": "^4.4.2", diff --git a/api/src/middlewares/TestClient.ts b/api/src/middlewares/TestClient.ts index 7d981f0c..b50f4e5c 100644 --- a/api/src/middlewares/TestClient.ts +++ b/api/src/middlewares/TestClient.ts @@ -23,10 +23,15 @@ export default function TestClient(app: Application) { if (GATEWAY_ENDPOINT) { html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: \`${GATEWAY_ENDPOINT}\`,`); } - - //plugins - var files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "plugins")); + // inline plugins + var files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "preload-plugins")); var plugins = ""; + files.forEach(x =>{if(x.endsWith(".js")) plugins += `\n`; }); + html = html.replaceAll("", plugins); + + // plugins + files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "plugins")); + plugins = ""; files.forEach(x =>{if(x.endsWith(".js")) plugins += `\n`; }); html = html.replaceAll("", plugins); //preload plugins -- cgit 1.4.1