loop: baseline
This commit is contained in:
+2
-2
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user