File size: 1,440 Bytes
8e2aea8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
import os
import secrets
from pydantic_settings import BaseSettings, SettingsConfigDict
from pathlib import Path

# Get project root
BASE_DIR = Path(__file__).parent.parent.parent


class Settings(BaseSettings):
    # App Settings
    PROJECT_NAME: str = "1proxy"
    API_V1_STR: str = "/api/v1"

    # SECRET_KEY: Auto-generate secure default for HuggingFace/development
    # IMPORTANT: Set this in production via environment variable!
    SECRET_KEY: str = os.getenv("SECRET_KEY", secrets.token_urlsafe(32))

    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7  # 7 days

    # URLs - Auto-detect HuggingFace Space environment
    API_URL: str = (
        os.getenv("SPACE_HOST", "").replace("https://", "https://")
        if os.getenv("SPACE_HOST")
        else "http://localhost:8000"
    )
    FRONTEND_URL: str = os.getenv("SPACE_HOST", "http://localhost:3000")

    # OAuth
    GITHUB_CLIENT_ID: str = ""
    GITHUB_CLIENT_SECRET: str = ""
    GOOGLE_CLIENT_ID: str = ""
    GOOGLE_CLIENT_SECRET: str = ""

    # Admin Access - GitHub Repository Collaboration
    # Users with admin/owner/collaborator access to this repo get admin role
    GITHUB_REPO_OWNER: str = ""
    GITHUB_REPO_NAME: str = ""

    # Database
    DATABASE_URL: str = "sqlite+aiosqlite:///./data/1proxy.db"

    model_config = SettingsConfigDict(
        env_file=str(BASE_DIR / ".env"), env_file_encoding="utf-8", extra="ignore"
    )


settings = Settings()