mirror of
https://github.com/spacebarchat/server.git
synced 2026-04-05 12:55:43 +00:00
Fix ESM error caused by file-type
This commit is contained in:
BIN
bundle/package-lock.json
generated
BIN
bundle/package-lock.json
generated
Binary file not shown.
@@ -69,7 +69,7 @@
|
||||
"dotenv": "^16.0.1",
|
||||
"exif-be-gone": "^1.3.0",
|
||||
"express": "^4.17.1",
|
||||
"file-type": "^17.1.4",
|
||||
"file-type": "16.5",
|
||||
"form-data": "^4.0.0",
|
||||
"i18next": "^21.8.14",
|
||||
"i18next-http-middleware": "^3.1.3",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"dotenv": "^16.0.1",
|
||||
"exif-be-gone": "^1.3.0",
|
||||
"express": "^4.17.1",
|
||||
"file-type": "^17.1.4",
|
||||
"file-type": "16.5",
|
||||
"image-size": "^1.0.0",
|
||||
"jest": "^28.1.3",
|
||||
"lambert-server": "^1.2.12",
|
||||
|
||||
@@ -68,7 +68,7 @@ router.get(
|
||||
`attachments/${channel_id}/${id}/${filename}`
|
||||
);
|
||||
if (!file) throw new HTTPError("File not found");
|
||||
const type = await FileType.fileTypeFromBuffer(file);
|
||||
const type = await FileType.fromBuffer(file);
|
||||
let content_type = type?.mime || "application/octet-stream";
|
||||
|
||||
if (SANITIZED_CONTENT_TYPE.includes(content_type)) {
|
||||
|
||||
@@ -38,7 +38,7 @@ router.post(
|
||||
.update(Snowflake.generate())
|
||||
.digest("hex");
|
||||
|
||||
const type = await FileType.fileTypeFromBuffer(buffer);
|
||||
const type = await FileType.fromBuffer(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
|
||||
@@ -65,7 +65,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.fileTypeFromBuffer(file);
|
||||
const type = await FileType.fromBuffer(file);
|
||||
|
||||
res.set("Content-Type", type?.mime);
|
||||
res.set("Cache-Control", "public, max-age=31536000");
|
||||
@@ -80,7 +80,7 @@ router.get("/:user_id/:hash", async (req: Request, res: Response) => {
|
||||
|
||||
const file = await storage.get(path);
|
||||
if (!file) throw new HTTPError("not found", 404);
|
||||
const type = await FileType.fileTypeFromBuffer(file);
|
||||
const type = await FileType.fromBuffer(file);
|
||||
|
||||
res.set("Content-Type", type?.mime);
|
||||
res.set("Cache-Control", "public, max-age=31536000");
|
||||
|
||||
@@ -48,7 +48,7 @@ router.get("/:id", async (req: Request, res: Response) => {
|
||||
|
||||
const file = await storage.get(`/external/${id}`);
|
||||
if (!file) throw new HTTPError("File not found");
|
||||
const result = await FileType.fileTypeFromBuffer(file);
|
||||
const result = await FileType.fromBuffer(file);
|
||||
|
||||
res.set("Content-Type", result?.mime);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ router.post(
|
||||
.update(Snowflake.generate())
|
||||
.digest("hex");
|
||||
|
||||
const type = await FileType.fileTypeFromBuffer(buffer);
|
||||
const type = await FileType.fromBuffer(buffer);
|
||||
if (!type || !ALLOWED_MIME_TYPES.includes(type.mime))
|
||||
throw new HTTPError("Invalid file type");
|
||||
|
||||
@@ -64,7 +64,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.fileTypeFromBuffer(file);
|
||||
const type = await FileType.fromBuffer(file);
|
||||
|
||||
res.set("Content-Type", type?.mime);
|
||||
res.set("Cache-Control", "public, max-age=31536000, must-revalidate");
|
||||
@@ -79,7 +79,7 @@ router.get("/:role_id/:hash", async (req: Request, res: Response) => {
|
||||
|
||||
const file = await storage.get(path);
|
||||
if (!file) throw new HTTPError("not found", 404);
|
||||
const type = await FileType.fileTypeFromBuffer(file);
|
||||
const type = await FileType.fromBuffer(file);
|
||||
|
||||
res.set("Content-Type", type?.mime);
|
||||
res.set("Cache-Control", "public, max-age=31536000, must-revalidate");
|
||||
|
||||
BIN
package-lock.json
generated
BIN
package-lock.json
generated
Binary file not shown.
Reference in New Issue
Block a user