Files
vpn-control-panel/app/settings.py
smolkik-code 7c7c88621d Initial commit: VPN Control Panel
- FastAPI REST API with JWT auth
- aiogram 3 Telegram bot with admin middleware
- APScheduler daily tasks (expiry, reminders, revoke, sync)
- SQLAlchemy 2 async ORM with Alembic migrations
- Jinja2 admin panel (Dashboard, Users, Payments, Servers, Tariffs)
- VPN provider abstraction with MockProvider
- Stats service with revenue/subscription analytics
- Docker Compose (PostgreSQL + Redis + app)
- Healthcheck endpoint
2026-07-05 17:50:11 +07:00

54 lines
1.6 KiB
Python

from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=False,
extra="ignore",
)
app_name: str = "VPN Control Panel"
debug: bool = False
port: int = 8000
postgres_user: str = Field(default="vpn", alias="POSTGRES_USER")
postgres_password: str = Field(default="vpn_secret", alias="POSTGRES_PASSWORD")
postgres_db: str = Field(default="vpn_control", alias="POSTGRES_DB")
postgres_host: str = Field(default="localhost", alias="POSTGRES_HOST")
postgres_port: int = Field(default=5432, alias="POSTGRES_PORT")
@property
def database_url(self) -> str:
return (
f"postgresql+asyncpg://{self.postgres_user}:{self.postgres_password}"
f"@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}"
)
@property
def database_url_sync(self) -> str:
return (
f"postgresql://{self.postgres_user}:{self.postgres_password}"
f"@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}"
)
redis_url: str = "redis://localhost:6379/0"
bot_token: str = ""
admin_ids: list[int] = Field(default_factory=list)
admin_group_id: int = 0
admin_group_thread_id: int | None = None
jwt_secret: str = "change_me"
jwt_algorithm: str = "HS256"
jwt_access_expire_minutes: int = 30
jwt_refresh_expire_days: int = 30
outline_api_prefix: str = ""
outline_cert_sha256: str = ""
settings = Settings()