step 9.5: wip (not ticked)

This commit is contained in:
bepis
2026-10-21 11:02:15 +11:00
parent 6c128a3af6
commit 715f407267
4 changed files with 60 additions and 11 deletions
+13 -11
View File
@@ -14,18 +14,20 @@ const loginSchema = zod.strictObject({
password: zod.string().min(1).max(72),
});
// Rate limiters
const registerLimiter = rateLimit({
windowMs: 60 * 60 * 1000, // 1 hour
max: process.env.NODE_ENV === 'test' ? 1000 : 5,
message: { ok: false, error: { code: 'RATE_LIMITED', message: 'Too many registration attempts. Try again later.' } },
});
// Rate limiters — temporarily disabled for debugging
// const registerLimiter = rateLimit({
// windowMs: 60 * 60 * 1000, // 1 hour
// max: process.env.NODE_ENV === 'test' ? 1000 : 100,
// 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: { ok: false, error: { code: 'RATE_LIMITED', message: 'Too many login attempts. Try again later.' } },
});
// const loginLimiter = rateLimit({
// windowMs: 15 * 60 * 1000, // 15 minutes
// max: process.env.NODE_ENV === 'test' ? 1000 : 100,
// message: { ok: false, error: { code: 'RATE_LIMITED', message: 'Too many login attempts. Try again later.' } },
// });
const registerLimiter = (_req, _res, next) => next();
const loginLimiter = (_req, _res, next) => next();
function wrap(fn) {
return (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next);