54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
|
|
"""FastAPI приложение — Freelancer Match."""
|
||
|
|
|
||
|
|
import logging
|
||
|
|
from contextlib import asynccontextmanager
|
||
|
|
|
||
|
|
from fastapi import FastAPI
|
||
|
|
from fastapi.middleware.cors import CORSMiddleware
|
||
|
|
|
||
|
|
from app.config import settings
|
||
|
|
from app.api.auth import router as auth_router
|
||
|
|
from app.api.projects import router as projects_router
|
||
|
|
from app.api.proposals import router as proposals_router
|
||
|
|
from app.api.ai import router as ai_router
|
||
|
|
from app.api.escrow import router as escrow_router
|
||
|
|
|
||
|
|
logging.basicConfig(level=logging.INFO)
|
||
|
|
|
||
|
|
|
||
|
|
@asynccontextmanager
|
||
|
|
async def lifespan(app: FastAPI):
|
||
|
|
"""Запуск и остановка приложения."""
|
||
|
|
logging.info("🚀 Freelancer Match starting...")
|
||
|
|
yield
|
||
|
|
logging.info("🛑 Freelancer Match shutting down.")
|
||
|
|
|
||
|
|
|
||
|
|
app = FastAPI(
|
||
|
|
title="Freelancer Match API",
|
||
|
|
description="Площадка для фрилансеров с AI-матчингом и escrow-гарантом",
|
||
|
|
version="1.0.0",
|
||
|
|
lifespan=lifespan,
|
||
|
|
)
|
||
|
|
|
||
|
|
# CORS
|
||
|
|
app.add_middleware(
|
||
|
|
CORSMiddleware,
|
||
|
|
allow_origins=settings.ALLOWED_ORIGINS,
|
||
|
|
allow_credentials=True,
|
||
|
|
allow_methods=["*"],
|
||
|
|
allow_headers=["*"],
|
||
|
|
)
|
||
|
|
|
||
|
|
# Routes
|
||
|
|
app.include_router(auth_router)
|
||
|
|
app.include_router(projects_router)
|
||
|
|
app.include_router(proposals_router)
|
||
|
|
app.include_router(ai_router)
|
||
|
|
app.include_router(escrow_router)
|
||
|
|
|
||
|
|
|
||
|
|
@app.get("/api/health")
|
||
|
|
async def health():
|
||
|
|
return {"status": "ok", "service": "freelancer-match"}
|