aboutsummaryrefslogtreecommitdiffstats
path: root/lib/upload.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-03-11 10:20:46 -0800
committerAdam Soltys <[email protected]>2023-03-11 10:20:46 -0800
commit5955ff6969a5301c4413631b76cf2300d193f8ed (patch)
tree92d1269a098cb7c764ca92f7a40af9ee236ae5b1 /lib/upload.js
parent7fec7cc3e7c51a9892869732b5bfe65922ee7818 (diff)
downloadcoinos-server-5955ff6969a5301c4413631b76cf2300d193f8ed.tar.gz
coinos-server-5955ff6969a5301c4413631b76cf2300d193f8ed.zip
separate tips from amounts
Diffstat (limited to 'lib/upload.js')
-rw-r--r--lib/upload.js11
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);