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", "axios": "^1.13.2",
"express": "^5.2.1", "express": "^5.2.1",
"mariadb": "^3.4.5", "mariadb": "^3.4.5",
"sqlight": "^1.0.0-alpha.8",
"sqlite3": "^5.1.7",
"ws": "^8.18.3" "ws": "^8.18.3"
} }
} }

View File

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