- Add presign endpoint: POST /api/v1/transactions/presign - Add confirm endpoint: POST /api/v1/transactions/confirm - Add generate_presigned_put_url() to MinIO service with public endpoint support - Add public_endpoint field to MinioConfig - Keep legacy /upload endpoint as fallback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1017 B
Python
50 lines
1017 B
Python
from pathlib import Path
|
|
|
|
import yaml
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class MinioConfig(BaseModel):
|
|
endpoint: str
|
|
public_endpoint: str = ""
|
|
bucket: str = "snapledger"
|
|
access_key: str
|
|
secret_key: str
|
|
|
|
|
|
class PostgresConfig(BaseModel):
|
|
host: str
|
|
port: int = 5432
|
|
database: str = "snapledger"
|
|
user: str
|
|
password: str
|
|
|
|
@property
|
|
def dsn(self) -> str:
|
|
return (
|
|
f"postgresql://{self.user}:{self.password}"
|
|
f"@{self.host}:{self.port}/{self.database}"
|
|
)
|
|
|
|
|
|
class ApiConfig(BaseModel):
|
|
token: str
|
|
|
|
|
|
class AppConfig(BaseModel):
|
|
minio: MinioConfig
|
|
postgresql: PostgresConfig
|
|
api: ApiConfig
|
|
|
|
|
|
def load_config(path: str = "config.yaml") -> AppConfig:
|
|
config_path = Path(path)
|
|
if not config_path.exists():
|
|
raise FileNotFoundError(f"Configuration file not found: {path}")
|
|
with open(config_path, encoding="utf-8") as f:
|
|
data = yaml.safe_load(f)
|
|
return AppConfig(**data)
|
|
|
|
|
|
settings = load_config()
|