feat: add base FastAPI project structure with static frontend and API v1

This commit is contained in:
Lino Mallevaey
2025-08-18 00:22:50 +02:00
parent ff5026b8f7
commit 49bcb38261
14 changed files with 487 additions and 13 deletions

View File

@@ -0,0 +1,75 @@
from pydantic_settings import BaseSettings
from datetime import timedelta
class Settings(BaseSettings):
# =========================
# ENVIRONMENT
# =========================
ENV: str
# =========================
# DATABASE
# =========================
DATABASE_URL: str
# =========================
# FASTAPI
# =========================
DEBUG: bool = True
APP_TITLE: str = "MokPyo API"
APP_VERSION: str = "1.0.0"
APP_DESCRIPTION: str = "MokPyo"
APP_DOMAIN: str = "localhost"
STATIC_DIR: str = "app/static"
# =========================
# SERVER
# =========================
HOST: str = "0.0.0.0"
PORT: int = 8000
UVICORN_WORKERS: int = 4
# =========================
# SECURITY / AUTH
# =========================
SECRET_KEY: str
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
ALGORITHM: str = "HS256"
# =========================
# EMAIL (optionnel)
# =========================
SMTP_HOST: str = ""
SMTP_PORT: int = 587
SMTP_USER: str = ""
SMTP_PASSWORD: str = ""
EMAIL_FROM: str = ""
# =========================
# LOGGING
# =========================
LOG_LEVEL: str = "INFO"
LOG_FILE: str = "logs/app.log"
# =========================
# UPLOADS / FILES
# =========================
MAX_UPLOAD_SIZE: int = 10_485_760 # 10 MB
# =========================
# ORJSON
# =========================
ORJSON_STRICT: bool = True
@property
def access_token_expire(self) -> timedelta:
return timedelta(minutes=self.ACCESS_TOKEN_EXPIRE_MINUTES)
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
# Instance globale
settings = Settings()
print("test")