summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/middlewares/TestClient.ts21
-rw-r--r--api/src/routes/users/@me/devices.ts10
2 files changed, 24 insertions, 7 deletions
diff --git a/api/src/middlewares/TestClient.ts b/api/src/middlewares/TestClient.ts

index f93d0b3a..75fdf650 100644 --- a/api/src/middlewares/TestClient.ts +++ b/api/src/middlewares/TestClient.ts
@@ -8,6 +8,20 @@ export default function TestClient(app: Application) { const assetCache = new Map<string, { response: FetchResponse; buffer: Buffer }>(); const indexHTML = fs.readFileSync(path.join(__dirname, "..", "..", "client_test", "index.html"), { encoding: "utf8" }); + var html = indexHTML; + const CDN_ENDPOINT = (Config.get().cdn.endpointClient || Config.get()?.cdn.endpoint || process.env.CDN || "").replace( + /(https?)?(:\/\/?)/g, + "" + ); + const GATEWAY_ENDPOINT = Config.get().gateway.endpointClient || Config.get()?.gateway.endpoint || process.env.GATEWAY || ""; + + if (CDN_ENDPOINT) { + html = html.replace(/CDN_HOST: .+/, `CDN_HOST: \`${CDN_ENDPOINT}\`,`); + } + if (GATEWAY_ENDPOINT) { + html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: \`${GATEWAY_ENDPOINT}\`,`); + } + app.use("/assets", express.static(path.join(__dirname, "..", "assets"))); app.get("/assets/:file", async (req: Request, res: Response) => { @@ -52,13 +66,6 @@ export default function TestClient(app: Application) { app.get("*", (req: Request, res: Response) => { res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24); res.set("content-type", "text/html"); - var html = indexHTML; - const CDN_ENDPOINT = (Config.get()?.cdn.endpoint || process.env.CDN || "").replace(/(https?)?(:\/\/?)/g, ""); - const GATEWAY_ENDPOINT = Config.get()?.gateway.endpoint || process.env.GATEWAY || ""; - - if (CDN_ENDPOINT && Config.get().cdn.endpointClient) html = html.replace(/CDN_HOST: .+/, `CDN_HOST: "${CDN_ENDPOINT}",`); - if (GATEWAY_ENDPOINT && Config.get().gateway.endpointClient) - html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: "${GATEWAY_ENDPOINT}",`); res.send(html); }); diff --git a/api/src/routes/users/@me/devices.ts b/api/src/routes/users/@me/devices.ts new file mode 100644
index 00000000..b16ef783 --- /dev/null +++ b/api/src/routes/users/@me/devices.ts
@@ -0,0 +1,10 @@ +import { Router, Response, Request } from "express"; + +const router = Router(); + +router.post("/", (req: Request, res: Response) => { + // TODO: + res.sendStatus(204); +}); + +export default router;