PR for Implement Rate Limiting and Abuse Prevention#54
Open
clintjeff2 wants to merge 50 commits intoDistinctCodes:mainfrom
Open
PR for Implement Rate Limiting and Abuse Prevention#54clintjeff2 wants to merge 50 commits intoDistinctCodes:mainfrom
clintjeff2 wants to merge 50 commits intoDistinctCodes:mainfrom
Conversation
- Add PdfGenerationLog model with comprehensive tracking fields - Add PdfInputType enum for HTML/MARKDOWN distinction - Include metadata fields: input size, processing time, success status - Add error logging fields: error message and stack trace - Include request tracing: user agent, IP address, request ID - Add performance indexes for efficient querying - Establish foreign key relationship with User model
- Create PdfLogService for database logging operations - Add detailed PDF generation request logging with metadata - Implement user analytics with success rates and performance metrics - Add system-wide analytics for administrative monitoring - Include error pattern analysis for debugging support - Provide safe input snippet creation with sensitive data removal - Add request tracing and performance monitoring capabilities
- Add detailed request logging with unique request IDs - Implement safe input snippet creation for debugging - Add comprehensive error logging with stack traces - Include request metadata tracking (user agent, IP address) - Add new analytics endpoints for users and administrators - Implement processing time measurement and performance logging - Add error pattern analysis endpoint for system monitoring
- Add PdfLogService to PDF module providers - Import PrismaModule for database access - Export PdfLogService for potential use in other modules - Update module dependencies for logging functionality
Contributor
Author
|
Hello @yusuftomilola, please review and merge. Opened this over 5 days ago. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement Rate Limiting for PDF Generation API
Closes #16
Overview
This PR implements comprehensive rate limiting for the PDF generation endpoint to prevent abuse and ensure fair usage across all users.
Features Added
Rate Limiting
X-RateLimit-*) included in responsesViolation Logging
Configuration
PDF_RATE_LIMIT_WINDOW_MS: Time window (default: 60000ms)PDF_RATE_LIMIT_MAX_REQUESTS: Max requests per window (default: 20)PDF_RATE_LIMIT_TRACK_BY_USER: Enable user-based tracking (default: true)Analytics & Monitoring
GET /pdf/analytics/rate-limitsfor violation statisticsImplementation Details
New Files
src/pdf/services/rate-limit.service.ts- Core rate limiting logicsrc/pdf/guards/rate-limit.guard.ts- NestJS guard for route protectionsrc/pdf/tasks/rate-limit-cleanup.task.ts- Cleanup expired entriesModified Files
src/pdf/controllers/pdf.controller.ts- Added rate limiting and analyticssrc/pdf/pdf.module.ts- Integrated new services and dependenciesprisma/schema.prisma- AddedRateLimitViolationmodel.env.development&.env.example- Added configuration variablesDatabase Changes
Usage Example