11import express from "express" ;
22import multer from "multer" ;
3- import rateLimit from "express-rate-limit" ;
43import {
54 analyzeDocument ,
65 saveAnalysis ,
@@ -14,12 +13,6 @@ import { sendError } from "../utils/apiResponse.js";
1413
1514const router = express . Router ( ) ;
1615const MAX_ANALYZE_FILE_BYTES = Number ( process . env . MAX_ANALYZE_FILE_BYTES || 50 * 1024 * 1024 ) ;
17- const analyzeRateLimitConfig = {
18- windowMs : Number ( process . env . ANALYZE_RATE_WINDOW_MS || 60_000 ) ,
19- limit : Number ( process . env . ANALYZE_RATE_MAX || 40 ) ,
20- standardHeaders : true ,
21- legacyHeaders : false ,
22- } ;
2316const upload = multer ( {
2417 storage : multer . memoryStorage ( ) ,
2518 limits : { fileSize : MAX_ANALYZE_FILE_BYTES , files : 1 } ,
@@ -33,16 +26,16 @@ const upload = multer({
3326} ) ;
3427
3528// POST /api/analyze — run AI analysis (auth required)
36- router . post ( "/" , rateLimit ( analyzeRateLimitConfig ) , protect , enforceQuota ( "analyze" ) , upload . single ( "file" ) , analyzeDocument ) ;
29+ router . post ( "/" , protect , enforceQuota ( "analyze" ) , upload . single ( "file" ) , analyzeDocument ) ;
3730
3831// POST /api/analyze/save — manually save a result to history
39- router . post ( "/save" , rateLimit ( analyzeRateLimitConfig ) , protect , validateAnalyzeSavePayload , saveAnalysis ) ;
32+ router . post ( "/save" , protect , validateAnalyzeSavePayload , saveAnalysis ) ;
4033
4134// GET /api/analyze/history — fetch all saved analyses for the user
42- router . get ( "/history" , rateLimit ( analyzeRateLimitConfig ) , protect , getAnalysisHistory ) ;
35+ router . get ( "/history" , protect , getAnalysisHistory ) ;
4336
4437// DELETE /api/analyze/history/:id — delete a specific saved analysis
45- router . delete ( "/history/:id" , rateLimit ( analyzeRateLimitConfig ) , protect , deleteAnalysis ) ;
38+ router . delete ( "/history/:id" , protect , deleteAnalysis ) ;
4639
4740router . use ( ( err , req , res , next ) => {
4841 if ( err ?. message === "Only PDF files are supported" ) {
0 commit comments