Prettier
This commit is contained in:
@@ -56,7 +56,7 @@ router.post(
|
||||
};
|
||||
|
||||
return res.json(file);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
router.get(
|
||||
@@ -65,7 +65,7 @@ router.get(
|
||||
const { channel_id, id, filename } = req.params;
|
||||
|
||||
const file = await storage.get(
|
||||
`attachments/${channel_id}/${id}/${filename}`
|
||||
`attachments/${channel_id}/${id}/${filename}`,
|
||||
);
|
||||
if (!file) throw new HTTPError("File not found");
|
||||
const type = await FileType.fromBuffer(file);
|
||||
@@ -79,7 +79,7 @@ router.get(
|
||||
res.set("Cache-Control", "public, max-age=31536000");
|
||||
|
||||
return res.send(file);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
router.delete(
|
||||
@@ -94,7 +94,7 @@ router.delete(
|
||||
await storage.delete(path);
|
||||
|
||||
return res.send({ success: true });
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -55,7 +55,7 @@ router.post(
|
||||
size,
|
||||
url: `${endpoint}${req.baseUrl}/${user_id}/${hash}`,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
router.get("/:user_id", async (req: Request, res: Response) => {
|
||||
@@ -86,7 +86,7 @@ export const getAvatar = async (req: Request, res: Response) => {
|
||||
res.set("Cache-Control", "public, max-age=31536000");
|
||||
|
||||
return res.send(file);
|
||||
}
|
||||
};
|
||||
|
||||
router.get("/:user_id/:hash", getAvatar);
|
||||
|
||||
|
||||
@@ -66,14 +66,14 @@ router.get("/resize/:url", async (req: Request, res: Response) => {
|
||||
const { resizeHeightMax, resizeWidthMax } = Config.get().cdn;
|
||||
const w = Math.min(parseInt(width as string), resizeWidthMax ?? 100);
|
||||
const h = Math.min(parseInt(height as string), resizeHeightMax ?? 100);
|
||||
if (w < 1 || h < 1) throw new HTTPError("Width and height must be greater than 0");
|
||||
if (w < 1 || h < 1)
|
||||
throw new HTTPError("Width and height must be greater than 0");
|
||||
|
||||
let buffer, response;
|
||||
try {
|
||||
response = await fetch(url, DEFAULT_FETCH_OPTIONS);
|
||||
buffer = await response.buffer();
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
throw new HTTPError("Couldn't fetch website");
|
||||
}
|
||||
|
||||
@@ -84,7 +84,10 @@ router.get("/resize/:url", async (req: Request, res: Response) => {
|
||||
.toBuffer();
|
||||
|
||||
res.setHeader("Content-Disposition", "attachment");
|
||||
res.setHeader("Content-Type", response.headers.get("content-type") ?? "image/png");
|
||||
res.setHeader(
|
||||
"Content-Type",
|
||||
response.headers.get("content-type") ?? "image/png",
|
||||
);
|
||||
return res.end(resizedBuffer);
|
||||
});
|
||||
|
||||
|
||||
@@ -7,4 +7,4 @@ const router = Router();
|
||||
router.get("/:guild_id/users/:user_id/avatars/:hash", getAvatar);
|
||||
router.get("/:guild_id/users/:user_id/banners/:hash", getAvatar);
|
||||
|
||||
export default router;
|
||||
export default router;
|
||||
|
||||
@@ -54,7 +54,7 @@ router.post(
|
||||
size,
|
||||
url: `${endpoint}${req.baseUrl}/${role_id}/${hash}`,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
router.get("/:role_id", async (req: Request, res: Response) => {
|
||||
|
||||
Reference in New Issue
Block a user