
- Set up project structure with FastAPI application - Implement SQLAlchemy models for users, services, projects, team members, contacts - Create API endpoints for website functionality - Implement JWT authentication system with user roles - Add file upload functionality for media - Configure CORS and health check endpoints - Add database migrations with Alembic - Create comprehensive README with setup instructions
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
import os
|
|
from typing import List, Optional, Union
|
|
|
|
from pydantic import AnyHttpUrl, EmailStr, field_validator
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(env_file=".env", extra="ignore", case_sensitive=True)
|
|
|
|
# Base API settings
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Communications Agency API"
|
|
PROJECT_DESCRIPTION: str = "Backend API for a Communications and Creative Agency Website"
|
|
VERSION: str = "0.1.0"
|
|
|
|
# CORS settings
|
|
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
|
|
@field_validator("BACKEND_CORS_ORIGINS", mode="before")
|
|
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)
|
|
|
|
# Security settings
|
|
SECRET_KEY: str = os.environ.get("SECRET_KEY", "supersecretkey123")
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8 # 8 days
|
|
|
|
# Admin user
|
|
ADMIN_EMAIL: Optional[EmailStr] = None
|
|
ADMIN_PASSWORD: Optional[str] = None
|
|
|
|
# Database settings
|
|
DATABASE_URI: Optional[str] = None
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
|
|
|
|
settings = Settings() |