41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import os
|
|
import secrets
|
|
from pathlib import Path
|
|
|
|
from pydantic import field_validator
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# API configuration
|
|
API_V1_STR: str = "/api/v1"
|
|
SECRET_KEY: str = os.getenv("SECRET_KEY", secrets.token_urlsafe(32))
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = int(
|
|
os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", 60 * 24 * 8)
|
|
) # 8 days
|
|
|
|
# Project configuration
|
|
PROJECT_NAME: str = "Small Business Inventory Management System"
|
|
PROJECT_DESCRIPTION: str = "API for managing inventory for small businesses"
|
|
PROJECT_VERSION: str = "0.1.0"
|
|
|
|
# Database configuration
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
|
|
@field_validator("DB_DIR")
|
|
@classmethod
|
|
def create_db_dir(cls, v):
|
|
v.mkdir(parents=True, exist_ok=True)
|
|
return v
|
|
|
|
# Debug mode
|
|
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
|
|
|
# CORS configuration
|
|
BACKEND_CORS_ORIGINS: list[str] = ["*"]
|
|
|
|
model_config = SettingsConfigDict(case_sensitive=True)
|
|
|
|
|
|
settings = Settings()
|