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') 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.5.1