94 lines
3.8 KiB
Python
94 lines
3.8 KiB
Python
from __future__ import annotations
|
|
|
|
from pydantic import field_validator
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
case_sensitive=False,
|
|
)
|
|
|
|
# ── Application ──────────────────────────────────
|
|
APP_NAME: str = "core-api"
|
|
APP_ENV: str = "development"
|
|
DEBUG: bool = True
|
|
SECRET_KEY: str = "change-me-to-a-random-secret-key"
|
|
API_V1_PREFIX: str = "/api/v1"
|
|
|
|
# ── MariaDB ──────────────────────────────────────
|
|
MARIADB_HOST: str = "127.0.0.1"
|
|
MARIADB_PORT: int = 3306
|
|
MARIADB_USER: str = "root"
|
|
MARIADB_PASSWORD: str = "changeme"
|
|
MARIADB_DATABASE: str = "core_api"
|
|
|
|
@property
|
|
def MARIADB_DSN(self) -> str:
|
|
return (
|
|
f"mysql+aiomysql://{self.MARIADB_USER}:{self.MARIADB_PASSWORD}"
|
|
f"@{self.MARIADB_HOST}:{self.MARIADB_PORT}/{self.MARIADB_DATABASE}"
|
|
)
|
|
|
|
@property
|
|
def MARIADB_DSN_SYNC(self) -> str:
|
|
return (
|
|
f"mysql+pymysql://{self.MARIADB_USER}:{self.MARIADB_PASSWORD}"
|
|
f"@{self.MARIADB_HOST}:{self.MARIADB_PORT}/{self.MARIADB_DATABASE}"
|
|
)
|
|
|
|
# ── MongoDB ──────────────────────────────────────
|
|
MONGODB_URL: str = "mongodb://127.0.0.1:27017"
|
|
MONGODB_DATABASE: str = "core_api"
|
|
|
|
# ── Redis ────────────────────────────────────────
|
|
REDIS_URL: str = "redis://127.0.0.1:6379/0"
|
|
|
|
# ── JWT ──────────────────────────────────────────
|
|
JWT_SECRET_KEY: str = "change-me-jwt-secret"
|
|
JWT_ALGORITHM: str = "HS256"
|
|
JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
|
JWT_REFRESH_TOKEN_EXPIRE_DAYS: int = 7
|
|
|
|
# ── MQTT ─────────────────────────────────────────
|
|
MQTT_HOST: str = "127.0.0.1"
|
|
MQTT_PORT: int = 1883
|
|
MQTT_USERNAME: str = ""
|
|
MQTT_PASSWORD: str = ""
|
|
|
|
# ── Celery ───────────────────────────────────────
|
|
CELERY_BROKER_URL: str = "redis://127.0.0.1:6379/1"
|
|
CELERY_RESULT_BACKEND: str = "redis://127.0.0.1:6379/2"
|
|
|
|
# ── CORS ─────────────────────────────────────────
|
|
CORS_ORIGINS: list[str] = ["http://localhost:3000", "http://localhost:8080"]
|
|
|
|
@field_validator("CORS_ORIGINS", mode="before")
|
|
@classmethod
|
|
def assemble_cors_origins(cls, v: str | list[str]) -> list[str]:
|
|
if isinstance(v, str):
|
|
return [i.strip() for i in v.strip("[]").split(",") if i.strip()]
|
|
return v
|
|
|
|
# ── OAuth ────────────────────────────────────────
|
|
GOOGLE_CLIENT_ID: str = ""
|
|
GOOGLE_CLIENT_SECRET: str = ""
|
|
KAKAO_CLIENT_ID: str = ""
|
|
KAKAO_CLIENT_SECRET: str = ""
|
|
NAVER_CLIENT_ID: str = ""
|
|
NAVER_CLIENT_SECRET: str = ""
|
|
|
|
# ── SMTP ─────────────────────────────────────────
|
|
SMTP_HOST: str = "smtp.gmail.com"
|
|
SMTP_PORT: int = 587
|
|
SMTP_USERNAME: str = ""
|
|
SMTP_PASSWORD: str = ""
|
|
|
|
# ── Logging ──────────────────────────────────────
|
|
LOG_LEVEL: str = "DEBUG"
|
|
|
|
|
|
settings = Settings()
|