From f3d45a0f80b27b096f110efcc1ee8ccbfb233b36 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Tue, 12 Mar 2024 16:42:15 +0100 Subject: [PATCH] feat(asset-server-plugin): Update Sharp to v0.33.2 --- packages/asset-server-plugin/package.json | 8 ++++---- packages/asset-server-plugin/src/plugin.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/asset-server-plugin/package.json b/packages/asset-server-plugin/package.json index 7f17554b7c..255b48e4a8 100644 --- a/packages/asset-server-plugin/package.json +++ b/packages/asset-server-plugin/package.json @@ -26,7 +26,7 @@ "@types/express": "^4.17.21", "@types/fs-extra": "^11.0.4", "@types/node-fetch": "^2.6.11", - "@types/sharp": "^0.30.4", + "@types/sharp": "^0.32.0", "@vendure/common": "2.2.0-next.5", "@vendure/core": "2.2.0-next.5", "express": "^4.18.3", @@ -35,8 +35,8 @@ "typescript": "5.3.3" }, "dependencies": { - "file-type": "^16.5.3", - "fs-extra": "^11.1.1", - "sharp": "~0.32.5" + "file-type": "^19.0.0", + "fs-extra": "^11.2.0", + "sharp": "~0.33.2" } } diff --git a/packages/asset-server-plugin/src/plugin.ts b/packages/asset-server-plugin/src/plugin.ts index 98ddec08ba..b19da32d73 100644 --- a/packages/asset-server-plugin/src/plugin.ts +++ b/packages/asset-server-plugin/src/plugin.ts @@ -11,7 +11,7 @@ import { } from '@vendure/core'; import { createHash } from 'crypto'; import express, { NextFunction, Request, Response } from 'express'; -import { fromBuffer } from 'file-type'; +import { fileTypeFromBuffer } from 'file-type'; import fs from 'fs-extra'; import path from 'path'; @@ -244,7 +244,7 @@ export class AssetServerPlugin implements NestModule, OnApplicationBootstrap { const file = await AssetServerPlugin.assetStorage.readFileToBuffer(key); let mimeType = this.getMimeType(key); if (!mimeType) { - mimeType = (await fromBuffer(file))?.mime || 'application/octet-stream'; + mimeType = (await fileTypeFromBuffer(file))?.mime || 'application/octet-stream'; } res.contentType(mimeType); res.setHeader('content-security-policy', "default-src 'self'"); @@ -289,7 +289,7 @@ export class AssetServerPlugin implements NestModule, OnApplicationBootstrap { } let mimeType = this.getMimeType(cachedFileName); if (!mimeType) { - mimeType = (await fromBuffer(imageBuffer))?.mime || 'image/jpeg'; + mimeType = (await fileTypeFromBuffer(imageBuffer))?.mime || 'image/jpeg'; } res.set('Content-Type', mimeType); res.setHeader('content-security-policy', "default-src 'self'");