summary refs log tree commit diff
path: root/src/api/Server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/Server.ts')
-rw-r--r--src/api/Server.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/api/Server.ts b/src/api/Server.ts

index d371ed9c..5039b154 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts
@@ -24,6 +24,7 @@ import morgan from "morgan"; import path from "path"; import { red } from "picocolors"; import { initInstance } from "./util/handlers/Instance"; +import fs from "fs/promises"; const ASSETS_FOLDER = path.join(__dirname, "..", "..", "assets"); const PUBLIC_ASSETS_FOLDER = path.join(ASSETS_FOLDER, "public"); @@ -129,6 +130,13 @@ export class SpacebarServer extends Server { return res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "widget.html")); }); + app.get("/invite/:code", async (req, res) => { + const { code } = req.params; + const content = fs.readFile(path.join(PUBLIC_ASSETS_FOLDER, "invite.html"), "utf-8"); + res.set("Cache-Control", "public, max-age=21600"); + return res.send((await content).replace("{code}", code).replace("{serverName}", Config.get().general.serverName)); + }); + app.get("/_spacebar/api/schemas.json", (req, res) => { res.sendFile(path.join(ASSETS_FOLDER, "schemas.json")); });