From 7709c1efde9a1f3078171ee56985cd25511d6f7b Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 1 Dec 2023 11:36:35 -0800 Subject: biome formatter --- lib/upload.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'lib/upload.js') diff --git a/lib/upload.js b/lib/upload.js index e07b9b1a..39c4a07f 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -14,7 +14,7 @@ async function getSha256Hash(stream) { stream.pipe(hash); let hashValue; - hash.on("data", data => { + hash.on("data", (data) => { hashValue = data.toString("hex"); }); @@ -42,16 +42,10 @@ export default async (req, res) => { if (format !== "image" && !["jpg", "jpeg", "png"].includes(ext)) throw new Error("unsupported file type"); - let t = sharp() - .rotate() - .resize(width) - .webp(); + let t = sharp().rotate().resize(width).webp(); let processedBuffer = await streamToBuffer(s2.pipe(t)); - let hash = crypto - .createHash("sha256") - .update(processedBuffer) - .digest("hex"); + let hash = crypto.createHash("sha256").update(processedBuffer).digest("hex"); let filePath = `/app/data/uploads/${hash}.webp`; fs.writeFileSync(filePath, processedBuffer); @@ -62,7 +56,7 @@ export default async (req, res) => { function streamToBuffer(stream) { return new Promise((resolve, reject) => { const chunks = []; - stream.on("data", chunk => chunks.push(chunk)); + stream.on("data", (chunk) => chunks.push(chunk)); stream.on("end", () => resolve(Buffer.concat(chunks))); stream.on("error", reject); }); -- cgit v1.2.3