
- Set up project structure with FastAPI - Implement SQLAlchemy models for User and Task - Create Alembic migrations - Implement authentication with JWT - Add CRUD operations for tasks - Add task filtering and prioritization - Configure health check endpoint - Update README with project documentation
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from typing import List
|
|
from pathlib import Path
|
|
from pydantic import AnyHttpUrl, validator
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Task Manager API"
|
|
PROJECT_DESCRIPTION: str = "A REST API for managing tasks"
|
|
|
|
# CORS settings
|
|
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
|
|
@validator("BACKEND_CORS_ORIGINS", pre=True)
|
|
def assemble_cors_origins(cls, v: str | List[str]) -> List[str]:
|
|
if isinstance(v, str) and not v.startswith("["):
|
|
return [i.strip() for i in v.split(",")]
|
|
if isinstance(v, (list, str)):
|
|
return v
|
|
raise ValueError(v)
|
|
|
|
# JWT settings
|
|
SECRET_KEY: str = "CHANGE_ME_IN_PRODUCTION"
|
|
ALGORITHM: str = "HS256"
|
|
# 60 minutes * 24 hours * 7 days = 7 days
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7
|
|
|
|
# Database settings
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
case_sensitive=True,
|
|
)
|
|
|
|
|
|
settings = Settings() |