refactor: remove backward compatibility code for pre-launch baseline
Clean up accumulated backward-compat shims, deprecated wrappers, unused aliases, and legacy code across the codebase. Since the platform is not live yet, this establishes a clean baseline. Changes: - Delete deprecated middleware/context.py (RequestContext, get_request_context) - Remove unused factory get_store_email_settings_service() - Remove deprecated pagination_full macro, /admin/platform-homepage route - Remove ConversationResponse, InvoiceSettings* unprefixed aliases - Simplify celery_config.py (remove empty LEGACY_TASK_MODULES) - Standardize billing exceptions: *Error aliases → *Exception names - Consolidate duplicate TierNotFoundError/FeatureNotFoundError classes - Remove deprecated is_admin_request() from Store/PlatformContextManager - Remove is_platform_default field, MediaUploadResponse legacy flat fields - Remove MediaItemResponse.url alias, update JS to use file_url - Update all affected tests and documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -186,19 +186,19 @@ All middleware components follow a consistent naming pattern for maintainability
|
||||
```
|
||||
✅ Good:
|
||||
middleware/logging.py
|
||||
middleware/context.py
|
||||
middleware/store_context.py
|
||||
middleware/auth.py
|
||||
|
||||
❌ Avoid:
|
||||
middleware/logging_middleware.py
|
||||
middleware/context_middleware.py
|
||||
middleware/store_context_middleware.py
|
||||
middleware/auth_middleware.py
|
||||
```
|
||||
|
||||
**Rationale**:
|
||||
- Keeps names concise and consistent
|
||||
- Follows Django, Flask, and FastAPI conventions
|
||||
- Makes imports cleaner: `from middleware.logging import LoggingMiddleware`
|
||||
- Makes imports cleaner: `from middleware.store_context import StoreContextMiddleware`
|
||||
- Reduces redundancy (the `middleware/` directory already indicates the purpose)
|
||||
|
||||
#### Test File Naming: Mirror the Source File
|
||||
@@ -206,10 +206,9 @@ middleware/auth_middleware.py
|
||||
Test files directly mirror the middleware filename with a `test_` prefix:
|
||||
|
||||
```
|
||||
middleware/logging.py → tests/unit/middleware/test_logging.py
|
||||
middleware/context.py → tests/unit/middleware/test_context.py
|
||||
middleware/auth.py → tests/unit/middleware/test_auth.py
|
||||
middleware/logging.py → tests/unit/middleware/test_logging.py
|
||||
middleware/store_context.py → tests/unit/middleware/test_store_context.py
|
||||
middleware/auth.py → tests/unit/middleware/test_auth.py
|
||||
```
|
||||
|
||||
#### One Component Per File
|
||||
@@ -229,19 +228,15 @@ class FrontendTypeMiddleware: # ASGI wrapper for frontend detection
|
||||
class AuthManager: # Authentication logic
|
||||
```
|
||||
|
||||
> **Note**: The old `middleware/context.py` with `ContextMiddleware` and `RequestContext` is deprecated.
|
||||
> Use `FrontendTypeMiddleware` and `FrontendType` enum instead.
|
||||
> See [Frontend Detection Architecture](frontend-detection.md) for migration guide.
|
||||
|
||||
#### One Test File Per Component
|
||||
|
||||
Follow the Single Responsibility Principle - each test file tests exactly one component:
|
||||
|
||||
```
|
||||
✅ Good:
|
||||
tests/unit/middleware/test_logging.py # Tests only LoggingMiddleware
|
||||
tests/unit/middleware/test_context.py # Tests only ContextManager/Middleware
|
||||
tests/unit/middleware/test_decorators.py # Tests only rate_limit decorator
|
||||
tests/unit/middleware/test_logging.py # Tests only LoggingMiddleware
|
||||
tests/unit/middleware/test_store_context.py # Tests only StoreContextManager/Middleware
|
||||
tests/unit/middleware/test_decorators.py # Tests only rate_limit decorator
|
||||
|
||||
❌ Avoid:
|
||||
tests/unit/middleware/test_all_middleware.py # Tests multiple components
|
||||
@@ -261,12 +256,12 @@ When importing middleware components, use explicit imports:
|
||||
```python
|
||||
# ✅ Preferred - Explicit and clear
|
||||
from middleware.logging import LoggingMiddleware
|
||||
from middleware.context import ContextManager, RequestContext
|
||||
from middleware.store_context import StoreContextManager
|
||||
from middleware.auth import AuthManager
|
||||
|
||||
# ❌ Avoid - Less clear
|
||||
from middleware import logging_middleware
|
||||
from middleware import context_middleware
|
||||
from middleware import store_context_middleware
|
||||
```
|
||||
|
||||
**See**: [Complete Naming Conventions Guide](../development/naming-conventions.md) for project-wide standards.
|
||||
|
||||
Reference in New Issue
Block a user