|
|
|
@ -7,12 +7,14 @@ from typing import Optional, Final
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from fastapi import FastAPI, HTTPException, status
|
|
|
|
from fastapi import FastAPI, HTTPException, status
|
|
|
|
|
|
|
|
from fastapi.exceptions import RequestValidationError
|
|
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from pydantic import ValidationError
|
|
|
|
from pydantic import ValidationError
|
|
|
|
|
|
|
|
|
|
|
|
from slowapi import _rate_limit_exceeded_handler
|
|
|
|
from slowapi import _rate_limit_exceeded_handler
|
|
|
|
from slowapi.errors import RateLimitExceeded
|
|
|
|
from slowapi.errors import RateLimitExceeded
|
|
|
|
from sqlalchemy import inspect
|
|
|
|
from sqlalchemy import inspect
|
|
|
|
|
|
|
|
from sqlalchemy.exc import SQLAlchemyError
|
|
|
|
from sqlalchemy.orm import scoped_session
|
|
|
|
from sqlalchemy.orm import scoped_session
|
|
|
|
from sqlalchemy.ext.asyncio import async_scoped_session
|
|
|
|
from sqlalchemy.ext.asyncio import async_scoped_session
|
|
|
|
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
|
|
|
|
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
|
|
|
|
@ -47,6 +49,9 @@ app = FastAPI(exception_handlers=exception_handlers, openapi_url="", title="LCCA
|
|
|
|
version="0.1.0")
|
|
|
|
version="0.1.0")
|
|
|
|
app.state.limiter = limiter
|
|
|
|
app.state.limiter = limiter
|
|
|
|
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
|
|
|
|
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
|
|
|
|
|
|
|
|
app.add_exception_handler(HTTPException, handle_exception)
|
|
|
|
|
|
|
|
app.add_exception_handler(RequestValidationError, handle_exception)
|
|
|
|
|
|
|
|
app.add_exception_handler(SQLAlchemyError, handle_exception)
|
|
|
|
app.add_middleware(GZipMiddleware, minimum_size=2000)
|
|
|
|
app.add_middleware(GZipMiddleware, minimum_size=2000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|