diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-07-17 16:54:26 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-07-17 19:49:43 +1000 |
commit | e891ddb412494e511c00804bfe40962ef7f95e58 (patch) | |
tree | 6342a00d45ca99aa7d0822c7a516fd332737180c /cdn | |
parent | Attempt to fix headers being set after send to client in send message (diff) | |
download | server-e891ddb412494e511c00804bfe40962ef7f95e58.tar.xz |
Redirect guild profile cdn stuff to normal avatar route while guild profiles are TODO
Diffstat (limited to 'cdn')
-rw-r--r-- | cdn/src/Server.ts | 2 | ||||
-rw-r--r-- | cdn/src/routes/avatars.ts | 6 | ||||
-rw-r--r-- | cdn/src/routes/guilds.ts | 10 |
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 |