feat: centralized constants and enums for project-wide use

This commit is contained in:
syntaxbullet
2026-01-06 18:15:52 +01:00
parent c807fd4fd0
commit 34347f0c63
17 changed files with 144 additions and 63 deletions

View File

@@ -4,6 +4,7 @@ import { inventoryService } from "@/modules/inventory/inventory.service";
import { itemTransactions } from "@/db/schema";
import { withTransaction } from "@/lib/db";
import type { Transaction } from "@/lib/types";
import { TransactionType, ItemTransactionType } from "@/lib/constants";
// Module-level session storage
const sessions = new Map<string, TradeSession>();
@@ -25,7 +26,7 @@ const processTransfer = async (tx: Transaction, from: TradeParticipant, to: Trad
await economyService.modifyUserBalance(
from.id,
-from.offer.money,
'TRADE_OUT',
TransactionType.TRADE_OUT,
`Trade with ${to.username} (Thread: ${threadId})`,
to.id,
tx
@@ -33,7 +34,7 @@ const processTransfer = async (tx: Transaction, from: TradeParticipant, to: Trad
await economyService.modifyUserBalance(
to.id,
from.offer.money,
'TRADE_IN',
TransactionType.TRADE_IN,
`Trade with ${from.username} (Thread: ${threadId})`,
from.id,
tx
@@ -54,7 +55,7 @@ const processTransfer = async (tx: Transaction, from: TradeParticipant, to: Trad
relatedUserId: BigInt(to.id),
itemId: item.id,
quantity: -item.quantity,
type: 'TRADE_OUT',
type: ItemTransactionType.TRADE_OUT,
description: `Traded to ${to.username}`,
});
@@ -64,7 +65,7 @@ const processTransfer = async (tx: Transaction, from: TradeParticipant, to: Trad
relatedUserId: BigInt(from.id),
itemId: item.id,
quantity: item.quantity,
type: 'TRADE_IN',
type: ItemTransactionType.TRADE_IN,
description: `Received from ${from.username}`,
});
}