summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-09-29 21:22:46 +0200
committerRory& <root@rory.gay>2025-09-29 21:22:46 +0200
commit3a0bded7f2c704c6587d06e7de7ce0578b50ae02 (patch)
tree3435b6f3e4d74a1dd51d5de7221620e4f92ff431 /src
parentUpdate dotenv, express, nodemailer, missing-native-js-functions, bcrypt, i18n... (diff)
downloadserver-ts-3a0bded7f2c704c6587d06e7de7ce0578b50ae02.tar.xz
Update file-type
Diffstat (limited to 'src')
-rw-r--r--src/cdn/routes/attachments.ts6
-rw-r--r--src/cdn/routes/avatars.ts8
-rw-r--r--src/cdn/routes/badge-icons.ts4
-rw-r--r--src/cdn/routes/embed.ts6
-rw-r--r--src/cdn/routes/guild-profiles.ts8
-rw-r--r--src/cdn/routes/role-icons.ts8
6 files changed, 20 insertions, 20 deletions
diff --git a/src/cdn/routes/attachments.ts b/src/cdn/routes/attachments.ts

index 4c65bbb28..1f3bc9f91 100644 --- a/src/cdn/routes/attachments.ts +++ b/src/cdn/routes/attachments.ts
@@ -18,7 +18,7 @@ import { Config, hasValidSignature, NewUrlUserSignatureData, Snowflake, UrlSignResult } from "@spacebar/util"; import { Request, Response, Router } from "express"; -import FileType from "file-type"; +import { fileTypeFromBuffer } from "file-type"; import imageSize from "image-size"; import { HTTPError } from "lambert-server"; import { multer } from "../util/multer"; @@ -92,7 +92,7 @@ router.get("/:channel_id/:id/:filename", async (req: Request, res: Response) => const file = await storage.get(path); if (!file) throw new HTTPError("File not found"); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); let content_type = type?.mime || "application/octet-stream"; if (SANITIZED_CONTENT_TYPE.includes(content_type)) { @@ -153,7 +153,7 @@ router.put("/:channel_id/:batch_id/:attachment_id/:filename", multer.single("fil let mimeType = att.userOriginalContentType; if (att.userOriginalContentType === null) { - const ft = await FileType.fromBuffer(buffer); + const ft = await fileTypeFromBuffer(buffer); mimeType = att.contentType = ft?.mime || "application/octet-stream"; } diff --git a/src/cdn/routes/avatars.ts b/src/cdn/routes/avatars.ts
index 6af3243fa..7e96dde3b 100644 --- a/src/cdn/routes/avatars.ts +++ b/src/cdn/routes/avatars.ts
@@ -19,7 +19,7 @@ import { Router, Response, Request } from "express"; import { Config, Snowflake } from "@spacebar/util"; import { storage } from "../util/Storage"; -import FileType from "file-type"; +import { fileTypeFromBuffer } from "file-type"; import { HTTPError } from "lambert-server"; import crypto from "crypto"; import { multer } from "../util/multer"; @@ -56,7 +56,7 @@ router.post( .update(Snowflake.generate()) .digest("hex"); - const type = await FileType.fromBuffer(buffer); + const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); if (ANIMATED_MIME_TYPES.includes(type.mime)) hash = `a_${hash}`; // animated icons have a_ infront of the hash @@ -83,7 +83,7 @@ router.get("/:user_id", async (req: Request, res: Response) => { const file = await storage.get(path); if (!file) throw new HTTPError("not found", 404); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); res.set("Content-Type", type?.mime); res.set("Cache-Control", "public, max-age=31536000"); @@ -99,7 +99,7 @@ export const getAvatar = async (req: Request, res: Response) => { const file = await storage.get(path); if (!file) throw new HTTPError("not found", 404); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); res.set("Content-Type", type?.mime); res.set("Cache-Control", "public, max-age=31536000"); diff --git a/src/cdn/routes/badge-icons.ts b/src/cdn/routes/badge-icons.ts
index 04e96f2fa..44dd4c8f2 100644 --- a/src/cdn/routes/badge-icons.ts +++ b/src/cdn/routes/badge-icons.ts
@@ -18,7 +18,7 @@ import { Router, Response, Request } from "express"; import { storage } from "../util/Storage"; -import FileType from "file-type"; +import { fileTypeFromBuffer } from "file-type"; import { HTTPError } from "lambert-server"; const router = Router(); @@ -29,7 +29,7 @@ router.get("/:badge_id", async (req: Request, res: Response) => { const file = await storage.get(path); if (!file) throw new HTTPError("not found", 404); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); res.set("Content-Type", type?.mime); res.set("Cache-Control", "public, max-age=31536000, must-revalidate"); diff --git a/src/cdn/routes/embed.ts b/src/cdn/routes/embed.ts
index 95ac720d8..d0bb620fe 100644 --- a/src/cdn/routes/embed.ts +++ b/src/cdn/routes/embed.ts
@@ -17,7 +17,7 @@ */ import { Request, Response, Router } from "express"; -import FileType from "file-type"; +import { fileTypeFromBuffer } from "file-type"; import fs from "fs/promises"; import { HTTPError } from "lambert-server"; import { join } from "path"; @@ -75,7 +75,7 @@ router.get("/avatars/:id", async (req: Request, res: Response) => { const file = await getFile(path); if (!file) throw new HTTPError("not found", 404); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); res.set("Content-Type", type?.mime); res.set("Cache-Control", "public, max-age=31536000"); @@ -100,7 +100,7 @@ router.get("/group-avatars/:id", async (req: Request, res: Response) => { const file = await getFile(path); if (!file) throw new HTTPError("not found", 404); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); res.set("Content-Type", type?.mime); res.set("Cache-Control", "public, max-age=31536000"); diff --git a/src/cdn/routes/guild-profiles.ts b/src/cdn/routes/guild-profiles.ts
index 1ee5eecae..4fcf1f397 100644 --- a/src/cdn/routes/guild-profiles.ts +++ b/src/cdn/routes/guild-profiles.ts
@@ -19,7 +19,7 @@ import { Config, Snowflake } from "@spacebar/util"; import crypto from "crypto"; import { Request, Response, Router } from "express"; -import FileType from "file-type"; +import { fileTypeFromBuffer } from "file-type"; import { HTTPError } from "lambert-server"; import { multer } from "../util/multer"; import { storage } from "../util/Storage"; @@ -53,7 +53,7 @@ router.post("/", multer.single("file"), async (req: Request, res: Response) => { .update(Snowflake.generate()) .digest("hex"); - const type = await FileType.fromBuffer(buffer); + const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); if (ANIMATED_MIME_TYPES.includes(type.mime)) hash = `a_${hash}`; // animated icons have a_ infront of the hash @@ -79,7 +79,7 @@ router.get("/", async (req: Request, res: Response) => { const file = await storage.get(path); if (!file) throw new HTTPError("not found", 404); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); res.set("Content-Type", type?.mime); res.set("Cache-Control", "public, max-age=31536000"); @@ -95,7 +95,7 @@ router.get("/:hash", async (req: Request, res: Response) => { const file = await storage.get(path); if (!file) throw new HTTPError("not found", 404); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); res.set("Content-Type", type?.mime); res.set("Cache-Control", "public, max-age=31536000"); diff --git a/src/cdn/routes/role-icons.ts b/src/cdn/routes/role-icons.ts
index 8040405a4..2d4f662c7 100644 --- a/src/cdn/routes/role-icons.ts +++ b/src/cdn/routes/role-icons.ts
@@ -19,7 +19,7 @@ import { Router, Response, Request } from "express"; import { Config, Snowflake } from "@spacebar/util"; import { storage } from "../util/Storage"; -import FileType from "file-type"; +import { fileTypeFromBuffer } from "file-type"; import { HTTPError } from "lambert-server"; import crypto from "crypto"; import { multer } from "../util/multer"; @@ -56,7 +56,7 @@ router.post( .update(Snowflake.generate()) .digest("hex"); - const type = await FileType.fromBuffer(buffer); + const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); @@ -82,7 +82,7 @@ router.get("/:role_id", async (req: Request, res: Response) => { const file = await storage.get(path); if (!file) throw new HTTPError("not found", 404); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); res.set("Content-Type", type?.mime); res.set("Cache-Control", "public, max-age=31536000, must-revalidate"); @@ -114,7 +114,7 @@ router.get("/:role_id/:hash", async (req: Request, res: Response) => { } if (!file) throw new HTTPError("not found", 404); - const type = await FileType.fromBuffer(file); + const type = await fileTypeFromBuffer(file); res.set("Content-Type", type?.mime); res.set("Cache-Control", "public, max-age=31536000, must-revalidate");