From 29df169c81d963742cc973a8835a7c1a126d7220 Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 19 Feb 2024 10:09:50 +0000 Subject: Add nix flake to repo (#1111) --- src/cdn/routes/embed.ts | 20 ++++++++++++++++++-- src/util/connections/ConnectionLoader.ts | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cdn/routes/embed.ts b/src/cdn/routes/embed.ts index 9d3469cd..b99396eb 100644 --- a/src/cdn/routes/embed.ts +++ b/src/cdn/routes/embed.ts @@ -63,7 +63,15 @@ router.get("/avatars/:id", async (req: Request, res: Response) => { id = id.split(".")[0]; // remove .file extension const hash = defaultAvatarHashMap.get(id); if (!hash) throw new HTTPError("not found", 404); - const path = join(process.cwd(), "assets", "public", `${hash}.png`); + const path = join( + __dirname, + "..", + "..", + "..", + "assets", + "public", + `${hash}.png`, + ); const file = await getFile(path); if (!file) throw new HTTPError("not found", 404); @@ -80,7 +88,15 @@ router.get("/group-avatars/:id", async (req: Request, res: Response) => { id = id.split(".")[0]; // remove .file extension const hash = defaultGroupDMAvatarHashMap.get(id); if (!hash) throw new HTTPError("not found", 404); - const path = join(process.cwd(), "assets", "public", `${hash}.png`); + const path = join( + __dirname, + "..", + "..", + "..", + "assets", + "public", + `${hash}.png`, + ); const file = await getFile(path); if (!file) throw new HTTPError("not found", 404); diff --git a/src/util/connections/ConnectionLoader.ts b/src/util/connections/ConnectionLoader.ts index e9dc6973..31b8e04b 100644 --- a/src/util/connections/ConnectionLoader.ts +++ b/src/util/connections/ConnectionLoader.ts @@ -22,7 +22,7 @@ import path from "path"; import { ConnectionConfig } from "./ConnectionConfig"; import { ConnectionStore } from "./ConnectionStore"; -const root = "dist/connections"; +const root = path.join(__dirname, "..", "..", "connections"); const connectionsLoaded = false; export class ConnectionLoader { -- cgit 1.4.1