diff options
author | The Arcane Brony <myrainbowdash949@gmail.com> | 2021-10-20 17:54:54 +0200 |
---|---|---|
committer | The Arcane Brony <myrainbowdash949@gmail.com> | 2021-11-11 22:24:03 +0100 |
commit | ed133380fbc74ef3b6930d1ea125205ffe2e36fc (patch) | |
tree | 9f0b79ee81e120f7c710a2dc04476eb95d05231c /api/src | |
parent | Merge pull request #496 from fosscord/translation (diff) | |
download | server-ed133380fbc74ef3b6930d1ea125205ffe2e36fc.tar.xz |
Add plugin & css support, add styling to differentiate from discord.com
Diffstat (limited to 'api/src')
-rw-r--r-- | api/src/middlewares/TestClient.ts | 14 |
1 files changed, 13 insertions, 1 deletions
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 += `<script src='/assets/plugins/${x}'></script>\n`; }); + html = html.replaceAll("<!-- plugin marker -->", plugins); + //preload plugins + files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "preload-plugins")); + plugins = ""; + files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script>${fs.readFileSync(path.join(__dirname, "..", "..", "assets", "preload-plugins", x))}</script>\n`; }); + html = html.replaceAll("<!-- preload plugin marker -->", 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; |