summary refs log tree commit diff
path: root/src/routes
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-07-01 16:02:54 +0200
committerGitHub <noreply@github.com>2021-07-01 16:02:54 +0200
commit7b31ca10b3c22c923cc1daf28f209c743e6b36fd (patch)
tree542a1f62dc30c96dd6e178c472e0382e67fd3be0 /src/routes
parent:construction: rate limit (diff)
parent:sparkles: finished Rate Limit (diff)
downloadserver-7b31ca10b3c22c923cc1daf28f209c743e6b36fd.tar.xz
Merge pull request #162 from fosscord/feat--rate-limit
[Feature] Rate Limit
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/guilds/#guild_id/widget.png.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/routes/guilds/#guild_id/widget.png.ts b/src/routes/guilds/#guild_id/widget.png.ts

index ea947c5d..839a8129 100644 --- a/src/routes/guilds/#guild_id/widget.png.ts +++ b/src/routes/guilds/#guild_id/widget.png.ts
@@ -1,9 +1,8 @@ import { Request, Response, Router } from "express"; import { GuildModel } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; -import { Image } from "canvas"; import fs from "fs"; -import path from "path" +import path from "path"; const router: Router = Router(); @@ -35,7 +34,7 @@ router.get("/", async (req: Request, res: Response) => { const sizeOf = require("image-size"); // TODO: Widget style templates need Fosscord branding - const source = path.join(__dirname, "..", "..", "..", "..", "assets","widget", `${style}.png`) + const source = path.join(__dirname, "..", "..", "..", "..", "assets", "widget", `${style}.png`); if (!fs.existsSync(source)) { throw new HTTPError("Widget template does not exist.", 400); } @@ -85,16 +84,17 @@ router.get("/", async (req: Request, res: Response) => { }); async function drawIcon(canvas: any, x: number, y: number, scale: number, icon: string) { - const img = new Image(); + // @ts-ignore + const img = new require("canvas").Image(); img.src = icon; - + // Do some canvas clipping magic! canvas.save(); canvas.beginPath(); const r = scale / 2; // use scale to determine radius canvas.arc(x + r, y + r, r, 0, 2 * Math.PI, false); // start circle at x, and y coords + radius to find center - + canvas.clip(); canvas.drawImage(img, x, y, scale, scale);