Files
freelancer-match/backend/app/main.py
T

64 lines
1.9 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
from app.api.reviews import router as reviews_router
from app.api.milestones import router as milestones_router
from app.api.portfolio import router as portfolio_router
from app.api.skill_tests import router as skill_tests_router
from app.api.verification import router as verification_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.include_router(reviews_router)
app.include_router(milestones_router)
app.include_router(portfolio_router)
app.include_router(skill_tests_router)
app.include_router(verification_router)
@app.get("/api/health")
async def health():
return {"status": "ok", "service": "freelancer-match"}