29 lines
884 B
Python
29 lines
884 B
Python
import os
|
|
from pathlib import Path
|
|
import secrets
|
|
from typing import List
|
|
|
|
from pydantic_settings import BaseSettings
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Chat Application Backend"
|
|
|
|
# Security
|
|
SECRET_KEY: str = secrets.token_urlsafe(32)
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8 # 8 days
|
|
|
|
# CORS
|
|
CORS_ORIGINS: List[str] = ["*"]
|
|
|
|
# Database
|
|
# Use current working directory as base by default, or app directory if in container
|
|
BASE_DIR = Path(os.getenv("APP_BASE_DIR", os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
|
|
DB_DIR = BASE_DIR / "app" / "storage" / "db"
|
|
DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
|
|
settings = Settings() |