mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
feat(rate-limit): add rate limit configuration for comment export
This commit is contained in:
@@ -13,12 +13,11 @@ import { logError } from '@/lib/logger';
|
||||
|
||||
type RouteParams = { params: Promise<{ versionId: string }> };
|
||||
const MAX_EXPORT_COMMENTS = 5000;
|
||||
const EXPORT_RATE_LIMIT = { windowMs: 60 * 1000, maxRequests: 10 };
|
||||
|
||||
// GET /api/versions/[versionId]/comments/export?format=csv|pdf&includeResolved=true|false
|
||||
export async function GET(request: NextRequest, { params }: RouteParams) {
|
||||
try {
|
||||
const limited = await rateLimit(request, 'comment-export', EXPORT_RATE_LIMIT);
|
||||
const limited = await rateLimit(request, 'comment-export');
|
||||
if (limited) return limited;
|
||||
|
||||
const session = await auth();
|
||||
|
||||
@@ -56,6 +56,9 @@ export const RATE_LIMIT_CONFIGS: Record<string, RateLimitConfig> = {
|
||||
// Watch progress — allow frequent updates but prevent abuse
|
||||
'watch-progress': { windowMs: 60 * 1000, maxRequests: 30 }, // 30 per minute (pausing + periodic + visibility changes)
|
||||
|
||||
// Exports
|
||||
'comment-export': { windowMs: 60 * 1000, maxRequests: 10 }, // 10 per minute
|
||||
|
||||
// Downloads — strict enough to limit upstream probing/cost abuse
|
||||
'video-download': { windowMs: 60 * 1000, maxRequests: 8 }, // 8 per minute
|
||||
'video-download-prepare': { windowMs: 60 * 1000, maxRequests: 5 }, // 5 per minute
|
||||
|
||||
Reference in New Issue
Block a user