Automated Action 77865dae90 Setup complete FastAPI backend with user authentication, client management, and invoice generation
Features:
- User authentication with JWT
- Client management with CRUD operations
- Invoice generation and management
- SQLite database with Alembic migrations
- Detailed project documentation
2025-05-26 17:41:47 +00:00

49 lines
1.4 KiB
Python

from pathlib import Path
from typing import List
from pydantic import BaseSettings, validator
class Settings(BaseSettings):
API_V1_STR: str = "/api/v1"
PROJECT_NAME: str = "Invoicing API"
PROJECT_DESCRIPTION: str = "Professional Invoicing API for Freelancers and Small Businesses"
VERSION: str = "0.1.0"
# CORS settings
BACKEND_CORS_ORIGINS: List[str] = ["*"]
@validator("BACKEND_CORS_ORIGINS", pre=True)
def assemble_cors_origins(cls, v: str | List[str]) -> List[str] | str:
if isinstance(v, str) and not v.startswith("["):
return [i.strip() for i in v.split(",")]
elif isinstance(v, (list, str)):
return v
raise ValueError(v)
# Database
DB_DIR: Path = Path("/app") / "storage" / "db"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
# JWT settings
SECRET_KEY: str = "YOUR_SECRET_KEY_HERE_PLEASE_CHANGE_THIS_IN_PRODUCTION"
ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7 # 7 days
# File storage
STORAGE_DIR: Path = Path("/app") / "storage"
INVOICE_STORAGE_DIR: Path = STORAGE_DIR / "invoices"
# Configure logging
LOG_LEVEL: str = "INFO"
class Config:
case_sensitive = True
env_file = ".env"
# Create all necessary directories
for dir_path in [Settings().DB_DIR, Settings().INVOICE_STORAGE_DIR]:
dir_path.mkdir(parents=True, exist_ok=True)
settings = Settings()