loop: baseline

This commit is contained in:
bepis
2026-10-20 20:33:35 +11:00
parent f1ae7b3119
commit 9a308b697d
32 changed files with 959 additions and 2046 deletions
+2 -2
View File
@@ -18,13 +18,13 @@ const loginSchema = zod.strictObject({
const registerLimiter = rateLimit({
windowMs: 60 * 60 * 1000, // 1 hour
max: process.env.NODE_ENV === 'test' ? 1000 : 5,
message: { error: { code: 'RATE_LIMITED', message: 'Too many registration attempts. Try again later.' } },
message: { ok: false, error: { code: 'RATE_LIMITED', message: 'Too many registration attempts. Try again later.' } },
});
const loginLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: process.env.NODE_ENV === 'test' ? 1000 : 10,
message: { error: { code: 'RATE_LIMITED', message: 'Too many login attempts. Try again later.' } },
message: { ok: false, error: { code: 'RATE_LIMITED', message: 'Too many login attempts. Try again later.' } },
});
function wrap(fn) {
+3 -9
View File
@@ -3,6 +3,7 @@ const zod = require('zod');
const { AppError } = require('../utils/errors');
const { requireAuth } = require('../middleware/session');
const { hunt } = require('../services/huntService');
const { getCharacterIdForUser } = require('../services/characterService');
// Validation schema
const huntSchema = zod.strictObject({
@@ -20,16 +21,9 @@ async function handleHunt(req, res) {
}
const { zoneId } = parsed.data;
const userId = req.session.userId;
// Get character ID for this user
const db = require('../db').getDb();
const character = db.prepare('SELECT id FROM characters WHERE user_id = ?').get(userId);
if (!character) {
throw new AppError('NO_CHARACTER', 'No character found.', 404);
}
const result = hunt(character.id, zoneId);
const characterId = getCharacterIdForUser(req.session.userId);
const result = hunt(characterId, zoneId);
res.json({
ok: true,