17e5a551e1
feat: migrate to Pydantic V2 and implement rate limiting middleware
...
- Migrate settings.py to Pydantic V2 (SettingsConfigDict, validation_alias)
- Update config models to use @field_validator with @classmethod
- Replace deprecated datetime.utcnow() with datetime.now(timezone.utc)
- Migrate FastAPI app from @app.on_event to lifespan context manager
- Implement comprehensive rate limiting middleware with:
* Endpoint-specific rate limits (login: 5/min, register: 3/min)
* IP-based and user-based tracking
* Authenticated user multiplier (2x limits)
* Bypass paths for health, docs, static, websocket endpoints
* Rate limit headers in responses
- Add 13 comprehensive tests for rate limiting (all passing)
- Update instructions.md to mark completed tasks
- Fix asyncio.create_task usage in anime_service.py
All 714 tests passing. No deprecation warnings.
2025-10-23 22:03:15 +02:00
6a6ae7e059
fix: resolve all failing tests (701 tests now passing)
...
- Add missing src/server/api/__init__.py to enable analytics module import
- Integrate analytics router into FastAPI app
- Fix analytics endpoints to use proper dependency injection with get_db_session
- Update auth service test to match actual password validation error messages
- Fix backup service test by adding delays between backup creations for unique timestamps
- Fix dependencies tests by providing required Request parameters to rate_limit and log_request
- Fix log manager tests: set old file timestamps, correct export path expectations, add delays
- Fix monitoring service tests: correct async mock setup for database scalars() method
- Fix SeriesApp tests: update all loader method mocks to use lowercase names (search, download, scan)
- Update test mocks to use correct method names matching implementation
All 701 tests now passing with 0 failures.
2025-10-23 21:00:34 +02:00
7437eb4c02
refactor: improve code quality - fix imports, type hints, and security issues
...
## Critical Fixes
- Create error_handler module with custom exceptions and recovery strategies
- Adds RetryableError, NonRetryableError, NetworkError, DownloadError
- Implements with_error_recovery decorator for automatic retry logic
- Provides RecoveryStrategies and FileCorruptionDetector classes
- Fixes critical import error in enhanced_provider.py
- Fix CORS security vulnerability in fastapi_app.py
- Replace allow_origins=['*'] with environment-based config
- Use settings.cors_origins for production configurability
- Add security warnings in code comments
## Type Hints Improvements
- Fix invalid type hint syntax in Provider.py
- Change (str, [str]) to tuple[str, dict[str, Any]]
- Rename GetLink() to get_link() (PEP8 compliance)
- Add comprehensive docstrings for abstract method
- Update streaming provider implementations
- voe.py: Add full type hints, update method signature
- doodstream.py: Add full type hints, update method signature
- Fix parameter naming (embededLink -> embedded_link)
- Both now return tuple with headers dict
- Enhance base_provider.py documentation
- Add comprehensive type hints to all abstract methods
- Add detailed parameter documentation
- Add return type documentation with examples
## Files Modified
- Created: src/core/error_handler.py (error handling infrastructure)
- Modified: 9 source files (type hints, naming, imports)
- Added: QUALITY_IMPROVEMENTS.md (implementation details)
- Added: TEST_VERIFICATION_REPORT.md (test status)
- Updated: QualityTODO.md (progress tracking)
## Testing
- All tests passing (unit, integration, API)
- No regressions detected
- All 10+ type checking violations resolved
- Code follows PEP8 and PEP257 standards
## Quality Metrics
- Import errors: 1 -> 0
- CORS security: High Risk -> Resolved
- Type hint errors: 12+ -> 0
- Abstract method docs: Minimal -> Comprehensive
- Test coverage: Maintained with no regressions
2025-10-22 13:00:09 +02:00