Files
nyeki-api/nyekiapi/api/v2/__init__.py
T
2026-07-16 02:12:29 -03:00

36 lines
946 B
Python

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)