diff options
Diffstat (limited to 'lib/upload.js')
| -rw-r--r-- | lib/upload.js | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/upload.js b/lib/upload.js index 50c26cbf..cb14f459 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -10,9 +10,9 @@ import { g, s, db } from "$lib/db"; export default async (req, res) => { let { params: { type }, - user + user, } = req; - + if (!["banner", "profile"].includes(type)) throw new Error("invalid upload"); let data = await req.file(); @@ -28,12 +28,9 @@ export default async (req, res) => { let path = `/app/data/uploads/${name}`; let size = type === "banner" ? 1920 : 240; - let t = sharp() - .rotate() - .resize(size) - .webp(); + let t = sharp().rotate().resize(size).webp(); - await new Promise(r => pipeline(s2, t, fs.createWriteStream(path), r)); + await new Promise((r) => pipeline(s2, t, fs.createWriteStream(path), r)); user[type] = true; await s(`user:${user.id}`, user); |
