Archived
- Backend: Django REST Framework API with Bookmark and Note models - ViewSets with user-scoped querysets and select_related for N+1 prevention - Create/List/Detail/Update/Delete endpoints - Batch delete operations - Unique constraint on user+book+page for bookmarks - IsOwner permission class for object-level access control - Full serializer validation (page > 0, non-empty content, duplicate check) - 30+ pytest-django tests covering CRUD, auth, filtering, edge cases - Frontend: React TypeScript components - AnnotationsContext with useReducer for state management - BookmarkList, NoteList, AddAnnotationForm, AnnotationsDashboard - Inline note editing with immediate save - Batch delete support - API client with JWT auto-refresh interceptors - Paginated query hook for infinite scroll support - Responsive CSS with loading/empty states - Infrastructure: Django project with custom User model, JWT auth, CORS - PostgreSQL database models with proper FK and indexes - Django admin configuration for all models
42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application settings via pydantic-settings. Reads from env vars and .env."""
|
|
|
|
# Django
|
|
DJANGO_SECRET_KEY: str = "django-insecure-change-me-in-production"
|
|
DJANGO_DEBUG: bool = False
|
|
DJANGO_ALLOWED_HOSTS: list[str] = ["*"]
|
|
|
|
# PostgreSQL
|
|
DB_NAME: str = "cloud_reader"
|
|
DB_USER: str = "postgres"
|
|
DB_PASSWORD: str = "postgres"
|
|
DB_HOST: str = "localhost"
|
|
DB_PORT: int = 5432
|
|
|
|
# JWT
|
|
JWT_ACCESS_TOKEN_LIFETIME_MINUTES: int = 60
|
|
JWT_REFRESH_TOKEN_LIFETIME_DAYS: int = 7
|
|
|
|
# CORS
|
|
CORS_ALLOWED_ORIGINS: list[str] = [
|
|
"http://localhost:5173",
|
|
"http://localhost:3000",
|
|
]
|
|
|
|
@property
|
|
def DATABASE_URL(self) -> str:
|
|
return (
|
|
f"postgresql://{self.DB_USER}:{self.DB_PASSWORD}"
|
|
f"@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"
|
|
)
|
|
|
|
model_config = {"env_file": ".env", "env_file_encoding": "utf-8"}
|
|
|
|
|
|
settings = Settings() |