File size: 1,608 Bytes
571122c 60cc4ec 571122c e1c6d87 571122c f1fbb28 60cc4ec 2333542 79d1d64 60cc4ec 79d1d64 60cc4ec 571122c 60cc4ec 79d1d64 60cc4ec |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import os
from pathlib import Path
from dotenv import load_dotenv
from urllib.parse import quote_plus
from pydantic_settings import BaseSettings
load_dotenv()
class Settings(BaseSettings):
# Database settings
DATABASE_USER: str = os.getenv("PG_USER", "snapfeast_db_owner")
DATABASE_PASSWORD: str = os.getenv("PG_PASSWORD", "4fLiupkCsN5E")
DATABASE_HOST: str = os.getenv("PG_HOST", "ep-fancy-glade-a57hqsn3-pooler.us-east-2.aws.neon.tech")
DATABASE_PORT: int = os.getenv("PG_PORT", 5432)
DATABASE_NAME: str = os.getenv("PG_DATABASE", "snapdb")
JWT_SECRET_KEY: str = os.getenv("JWT_SECRET", "EjQFIgOWHqrzjZc23CfcY6RWi2F2yUMr67DRJlpkjSU")
# JWT settings
JWT_ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "30"))
REFRESH_TOKEN_EXPIRE_DAYS: int = int(os.getenv("REFRESH_TOKEN_EXPIRE_DAYS", "7"))
# Application settings
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
ALLOWED_HOSTS: list = os.getenv("ALLOWED_HOSTS", "*").split(",")
# Face recognition settings
FACE_RECOGNITION_THRESHOLD: float = float(os.getenv("FACE_RECOGNITION_THRESHOLD", "0.6"))
@property
def DATABASE_URL(self) -> str:
user = quote_plus(self.DATABASE_USER)
password = quote_plus(self.DATABASE_PASSWORD)
return f"postgresql://{user}:{password}@{self.DATABASE_HOST}:{self.DATABASE_PORT}/{self.DATABASE_NAME}?sslmode=require"
class Config:
env_file = ".env"
def get_settings() -> Settings:
return Settings()
# Usage example
settings = get_settings() |