- اتصال کامل فرانت به API: همه محتوای سایت (پروژهها، مقالات، خدمات، برند و...) از بکاند خوانده میشود (SiteProvider + useSite) - فرم تماس و خبرنامه متصل به بکاند و تستشده در مرورگر - ساختار مونوریپو: frontend/ + backend/ - Dockerfile برای هر دو بخش + docker-compose (PostgreSQL + FastAPI + nginx) - nginx با پروکسی /api — بدون نیاز به CORS در حالت داکر - README کامل فارسی
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from . import models # noqa: F401 — ثبت مدلها پیش از ساخت جداول
|
|
from .api import admin, forms, public
|
|
from .config import settings
|
|
from .database import Base, engine
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title="ArameshPlaza API",
|
|
description=(
|
|
"بکاند سایت آرامش پلازا — API محتوای سایت، فرم تماس و خبرنامه، "
|
|
"و پنل مدیریت با احراز هویت JWT."
|
|
),
|
|
version="1.0.0",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins,
|
|
allow_credentials=False,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(public.router, prefix="/api", tags=["عمومی"])
|
|
app.include_router(forms.router, prefix="/api", tags=["فرمها"])
|
|
app.include_router(admin.auth_router, prefix="/api", tags=["احراز هویت"])
|
|
app.include_router(admin.router, prefix="/api/admin", tags=["پنل مدیریت"])
|
|
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {
|
|
"app": "ArameshPlaza API",
|
|
"docs": "/docs",
|
|
"health": "/api/health",
|
|
}
|