Wire production domain, CORS for tenant subdomains, celery volume mounts, and nginx reverse proxy configs for apex, API, identity, auth, and wildcard tenants. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""ساختار پاسخ استاندارد API بین همه سرویسها.
|
|
|
|
هدف: یکپارچگی قالب پاسخها (موفق و خطا) در کل پلتفرم.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Generic, TypeVar
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
T = TypeVar("T")
|
|
|
|
|
|
class ErrorDetail(BaseModel):
|
|
code: str = Field(..., description="کد ماشینخوان خطا")
|
|
message: str = Field(..., description="پیام قابل نمایش خطا")
|
|
details: Any | None = Field(default=None, description="جزئیات تکمیلی")
|
|
|
|
|
|
class ErrorResponse(BaseModel):
|
|
"""قالب استاندارد پاسخ خطا."""
|
|
|
|
success: bool = False
|
|
error: ErrorDetail
|
|
|
|
|
|
class SuccessResponse(BaseModel, Generic[T]):
|
|
"""قالب استاندارد پاسخ موفق (اختیاری برای wrap کردن داده)."""
|
|
|
|
success: bool = True
|
|
data: T | None = None
|
|
|
|
|
|
class MessageResponse(BaseModel):
|
|
"""پاسخ ساده مبتنی بر پیام."""
|
|
|
|
success: bool = True
|
|
message: str
|