
- Set up FastAPI application structure - Implemented SQLite database integration with SQLAlchemy - Added Alembic migrations for database versioning - Created bet model and API endpoints for CRUD operations - Added comprehensive README with setup and usage instructions - Added health check endpoint and CORS support
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from pathlib import Path
|
|
from typing import List, Optional
|
|
|
|
from pydantic import AnyHttpUrl, BaseSettings, validator
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# API settings
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Sports Betting Verification API"
|
|
PROJECT_DESCRIPTION: str = "API for verifying sports betting information"
|
|
VERSION: str = "0.1.0"
|
|
|
|
# CORS settings
|
|
CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
|
|
# Add CORS origins validator
|
|
@validator("CORS_ORIGINS", pre=True)
|
|
def assemble_cors_origins(cls, v: Optional[str]) -> List[str]:
|
|
if isinstance(v, str) and not v.startswith("["):
|
|
return [i.strip() for i in v.split(",")]
|
|
elif isinstance(v, (list, str)):
|
|
return v
|
|
return []
|
|
|
|
# Database settings
|
|
DB_DIR: Path = Path("/app/storage/db")
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
env_file = ".env"
|
|
|
|
|
|
# Create settings instance
|
|
settings = Settings()
|
|
|
|
# Ensure DB directory exists
|
|
settings.DB_DIR.mkdir(parents=True, exist_ok=True) |