new version using better built-in api for create 6

This commit is contained in:
ZareMate 2025-12-30 06:09:28 +01:00
parent ac492b1301
commit 634d060c75
3 changed files with 13 additions and 1525 deletions

1504
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,8 +15,6 @@
"axios": "^1.13.2",
"express": "^5.2.1",
"mariadb": "^3.4.5",
"sqlight": "^1.0.0-alpha.8",
"sqlite3": "^5.1.7",
"ws": "^8.18.3"
}
}

View File

@ -380,16 +380,14 @@ module.exports = function (app, wss, pool) {
if (!userRow)
return res.status(404).json({ ok: false, error: "User not found" });
if (userRow.balance < price * item.quantity)
return res
.status(400)
.json({
ok: false,
error: `Insufficient balance for item ${item.id}`,
});
return res.status(400).json({
ok: false,
error: `Insufficient balance for item ${item.id}`,
});
const shopId = response.data.shopId;
if (!shopList[shopId]) shopList[shopId] = [];
shopList[shopId].push({ id: item.id, count: item.quantity });
shopList[shopId].push({ name: item.id, _requestCount: item.quantity });
total += price * item.quantity;
}
@ -418,12 +416,10 @@ module.exports = function (app, wss, pool) {
);
await conn.commit();
res
.status(200)
.json({
ok: true,
message: `Successfully purchased items for user ${userId} at ${total}`,
});
res.status(200).json({
ok: true,
message: `Successfully purchased items for user ${userId} at ${total}`,
});
} catch (err) {
await conn.rollback();
console.error(err);
@ -462,12 +458,10 @@ module.exports = function (app, wss, pool) {
);
await conn.commit();
res
.status(200)
.json({
ok: true,
message: `Successfully transferred ${amount} from ${from} to ${to}`,
});
res.status(200).json({
ok: true,
message: `Successfully transferred ${amount} from ${from} to ${to}`,
});
} catch (err) {
await conn.rollback();
console.error(err);