diff options
| author | Adam Soltys <[email protected]> | 2023-01-26 11:26:05 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-01-26 11:26:09 -0800 |
| commit | f0543b6d94081f43a265bb9f754a654df9c4268a (patch) | |
| tree | c2fee79d8e410a2b6914f2dd53d7abef19497e39 /lib/upload.js | |
| parent | 143490db49b6d67e9ddb2c59ea92ae923d08911c (diff) | |
| download | coinos-server-f0543b6d94081f43a265bb9f754a654df9c4268a.tar.gz coinos-server-f0543b6d94081f43a265bb9f754a654df9c4268a.zip | |
sample notify script
Diffstat (limited to 'lib/upload.js')
| -rw-r--r-- | lib/upload.js | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/upload.js b/lib/upload.js index fbf9ce20..5f5aebed 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -5,12 +5,16 @@ import fs from "fs"; import path from "path"; import sharp from "sharp"; import { pipeline } from "stream"; -import { g, s } from "$lib/db"; +import { g, s, db } from "$lib/db"; -export default async ({ params: { type }, file, user }, res) => { +export default async (req, res) => { + let { + params: { type }, + user + } = req; if (!["banner", "profile"].includes(type)) throw new Error("invalid upload"); - let data = await file(); + let data = await req.file(); let s1 = new Clone(data.file); let s2 = new Clone(data.file); @@ -30,14 +34,8 @@ export default async ({ params: { type }, file, user }, res) => { await new Promise(r => pipeline(s2, t, fs.createWriteStream(path), r)); - let r = async () => { - await db.watch(`user:${user.id}`); - user = await g(`user:${user.id}`); - user[type] = true; - let m = await db.multi(); - await s(`user:${user.id}`, user); - }; - await r(); + user[type] = true; + await s(`user:${user.id}`, user); res.send(name); }; |
