Add logging for /getSession

This commit is contained in:
Christopher Cookman 2025-01-20 19:14:55 -07:00
parent d89f167517
commit e6244a614a

View file

@ -10,6 +10,7 @@ router.get('/getSession', async (req, res) => {
try {
const pid = req.query.robloxPlayerId;
if (!pid) return res.status(400).json({ status: 400, message: 'Missing Roblox Player ID' });
log.info(`GET /hub/getSession?robloxPlayerId=${pid}`);
const [row] = await pool.query('SELECT * FROM users WHERE robloxId = ?', [pid]);
if (!row) {
const pairingCode = Math.floor(100000 + Math.random() * 900000).toString();
@ -27,8 +28,6 @@ router.get('/getSession', async (req, res) => {
const purchases = await pool.query('SELECT * FROM purchases WHERE hubId = ?', [hub.id]);
// Generate bestSeller object from purchases. Find what product id has the most sales, then make the object
const purchaseCounts = purchases.reduce((acc, purchase) => {
console.log(acc)
console.log(purchase)
acc[purchase.productId] = (acc[purchase.productId] || 0) + 1;
return acc;
}, {});