
- Create FastAPI app structure - Set up SQLAlchemy with SQLite for database management - Implement invoice and invoice item models - Add Alembic for database migrations - Create invoice generation and retrieval API endpoints - Add health check endpoint - Set up Ruff for linting - Update README with project details
29 lines
799 B
Python
29 lines
799 B
Python
from typing import List, Union
|
|
|
|
from pydantic import AnyHttpUrl, validator
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# API config
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Invoice Generation Service"
|
|
|
|
# CORS settings
|
|
BACKEND_CORS_ORIGINS: List[Union[str, AnyHttpUrl]] = []
|
|
|
|
@validator("BACKEND_CORS_ORIGINS", pre=True)
|
|
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[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)
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
env_file = ".env"
|
|
|
|
|
|
# Create settings instance
|
|
settings = Settings() |