feat-(all routes, models, migration completed)

This commit is contained in:
2026-11-06 13:39:33 +03:00
parent d1a8c0394b
commit 97caa7e8ff
21 changed files with 319 additions and 230 deletions
+4 -4
View File
@@ -2,7 +2,7 @@ from fastapi import FastAPI, Request, HTTPException
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
import os
from src.api.dependencies import generate_id, create_error_response
from src.utils import generate_id, create_error_response
from src.api.routes.health import health
from src.api.routes.users import user
from src.api.routes.chats import chat
@@ -15,7 +15,7 @@ application = FastAPI(title="MTUSI Messenger", version="1.0.0", lifespan=lifespa
@application.middleware("http")
async def add_request_id(request: Request, call_next):
request_id = generate_id()
request_id = str(generate_id())
request.state.request_id = request_id
response = await call_next(request)
response.headers["X-Request-Id"] = request_id
@@ -47,7 +47,7 @@ async def validation_exception_handler(request: Request, exc: RequestValidationE
async def http_exception_handler(request: Request, exc: HTTPException):
request_id = getattr(request.state, "request_id", None)
if request_id is None:
request_id = generate_id()
request_id = str(generate_id())
code_map = {
400: "invalid_request",
@@ -67,7 +67,7 @@ async def http_exception_handler(request: Request, exc: HTTPException):
async def global_exception_handler(request: Request, exc: Exception):
request_id = getattr(request.state, "request_id", None)
if request_id is None:
request_id = generate_id()
request_id = str(generate_id())
print(f'Internal Error: {exc}')
return create_error_response(message="Internal Server Error", code="internal_error", status_code=500, request_id=request_id)