summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--cdn/src/Server.ts2
-rw-r--r--cdn/src/routes/avatars.ts6
-rw-r--r--cdn/src/routes/guilds.ts10
3 files changed, 15 insertions, 3 deletions
diff --git a/cdn/src/Server.ts b/cdn/src/Server.ts

index b8d71fa9..5b395589 100644 --- a/cdn/src/Server.ts +++ b/cdn/src/Server.ts
@@ -5,7 +5,7 @@ import avatarsRoute from "./routes/avatars"; import iconsRoute from "./routes/role-icons"; import bodyParser from "body-parser"; -export interface CDNServerOptions extends ServerOptions {} +export interface CDNServerOptions extends ServerOptions { } export class CDNServer extends Server { public declare options: CDNServerOptions; diff --git a/cdn/src/routes/avatars.ts b/cdn/src/routes/avatars.ts
index 2a4a0ffe..e5e25a4c 100644 --- a/cdn/src/routes/avatars.ts +++ b/cdn/src/routes/avatars.ts
@@ -73,7 +73,7 @@ router.get("/:user_id", async (req: Request, res: Response) => { return res.send(file); }); -router.get("/:user_id/:hash", async (req: Request, res: Response) => { +export const getAvatar = async (req: Request, res: Response) => { var { user_id, hash } = req.params; hash = hash.split(".")[0]; // remove .file extension const path = `avatars/${user_id}/${hash}`; @@ -86,7 +86,9 @@ router.get("/:user_id/:hash", async (req: Request, res: Response) => { res.set("Cache-Control", "public, max-age=31536000"); return res.send(file); -}); +} + +router.get("/:user_id/:hash", getAvatar); router.delete("/:user_id/:id", async (req: Request, res: Response) => { if (req.headers.signature !== Config.get().security.requestSignature) diff --git a/cdn/src/routes/guilds.ts b/cdn/src/routes/guilds.ts new file mode 100644
index 00000000..3c4b646c --- /dev/null +++ b/cdn/src/routes/guilds.ts
@@ -0,0 +1,10 @@ +import { Router } from "express"; +import { getAvatar } from "./avatars"; + +const router = Router(); + +// TODO: handle guild profiles +router.get("/:guild_id/users/:user_id/avatars/:hash", getAvatar); +router.get("/:guild_id/users/:user_id/banners/:hash", getAvatar); + +export default router; \ No newline at end of file