from fastapi import FastAPI from fastapi.responses import ORJSONResponse from fastapi.exceptions import RequestValidationError from nyekiapi.lib import settings from nyekiapi.api import docs from nyekiapi.api.v2.errors import ( BaseError, NotFoundError, ValidationError, InternalServerError, ) from nyekiapi.api.v2.profiles.router import router as example_router app = FastAPI( debug=settings.DEBUG, title="Nyeki's API", version="2.0.0", docs_url=None, redoc_url="/docs", default_response_class=ORJSONResponse, ) app.include_router(example_router) app.add_exception_handler(BaseError, BaseError.handler) app.add_exception_handler(404, NotFoundError.handler) app.add_exception_handler(RequestValidationError, ValidationError.handler) app.add_exception_handler(500, InternalServerError.handler) app.add_exception_handler(Exception, InternalServerError.handler) docs.load_onto_fastapi("docs/v2", app)