feat(quality): Sprint 2 pre-deploy gates and server smoke tests
Extract Express app factory for testability, add Vitest/Supertest API smoke tests, root npm run check script, and deployment docs. Fix express-rate-limit IPv6 keyGenerator for feedback limiter. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import rateLimit from 'express-rate-limit'
|
||||
import rateLimit, { ipKeyGenerator } from 'express-rate-limit'
|
||||
import type { AuthedRequest } from './auth.js'
|
||||
|
||||
const MIN_SUBMIT_MS = 2_000
|
||||
@@ -69,7 +69,11 @@ export const feedbackLimiter = rateLimit({
|
||||
max: 5,
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
keyGenerator: (req) => (req as AuthedRequest).userId ?? req.ip ?? 'unknown',
|
||||
keyGenerator: (req) => {
|
||||
const authed = req as AuthedRequest
|
||||
if (authed.userId) return authed.userId
|
||||
return ipKeyGenerator(req.ip ?? 'unknown')
|
||||
},
|
||||
handler: (_req, res) => {
|
||||
res.status(429).json({
|
||||
error: 'Too many feedback submissions. Please try again later.',
|
||||
|
||||
Reference in New Issue
Block a user