Files
mtusi2026lab2/src/main.py
T
2026-10-09 14:57:52 +03:00

23 lines
966 B
Python

from fastapi import FastAPI
from fastapi.exceptions import RequestValidationError
from starlette.exceptions import HTTPException
from .errors import APIError, api_error_handler, validation_error_handler, http_error_handler, internal_error_handler
from .middleware import RequestIdMiddleware
from .limits import ResourceLimitMiddleware
from .routers.health import router as health_router
from .routers.users import router as users_router
from .routers.chats import router as chats_router
app = FastAPI(title="MTUSI Messenger")
app.add_middleware(ResourceLimitMiddleware)
app.add_middleware(RequestIdMiddleware)
app.add_exception_handler(APIError, api_error_handler)
app.add_exception_handler(RequestValidationError, validation_error_handler)
app.add_exception_handler(HTTPException, http_error_handler)
app.add_exception_handler(Exception, internal_error_handler)
app.include_router(health_router)
app.include_router(users_router)
app.include_router(chats_router)