Baseline md2vk: docs, audit log, docker 8420, openspec, deploy

This commit is contained in:
estorozhenko
2026-09-18 22:05:01 +00:00
commit 09e960a3a9
39 changed files with 3716 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
"""Конфигурация md2vk из переменных окружения."""
from __future__ import annotations
from pathlib import Path
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
# HTTP
host: str = "0.0.0.0"
port: int = 8000
# Файл с Fernet-ключом (Docker secret / файл на диске)
token_encryption_key_file: str = "/run/secrets/token_encryption_key"
# База данных
database_url: str = "sqlite+aiosqlite:///data/md2vk.db"
# VK API
vk_api_version: str = "5.199"
# Rate limiting (запросов в минуту на VK-аккаунт)
rate_limit_per_minute: int = 10
model_config = {"env_file": ".env", "env_prefix": ""}
@property
def fernet_key(self) -> bytes:
"""Читает и возвращает Fernet-ключ из файла."""
key_path = Path(self.token_encryption_key_file)
if not key_path.exists():
raise RuntimeError(
f"Файл с Fernet-ключом не найден: {key_path}. "
f"Сгенерируйте: python3 -c \"from cryptography.fernet import Fernet; "
f"print(Fernet.generate_key().decode())\" > {key_path}"
)
return key_path.read_bytes().strip()
settings = Settings()