Skip to content

Usage with Fastapi

Another example of usage with FastAPI - fastapi-sqlalchemy-template

1. Install lite-bootstrap[fastapi-all]:

uv add lite-bootstrap[fastapi-all]
pip install lite-bootstrap[fastapi-all]
poetry add lite-bootstrap[fastapi-all]

Read more about available extras here:

2. Define bootstrapper config and build you application:

from lite_bootstrap import FastAPIConfig, FastAPIBootstrapper


bootstrapper_config = FastAPIConfig(
    service_name="microservice",
    service_version="2.0.0",
    service_environment="test",
    cors_allowed_origins=["http://test"],
    health_checks_path="/custom-health/",
    opentelemetry_endpoint="otl",
    prometheus_metrics_path="/custom-metrics/",
    sentry_dsn="https://testdsn@localhost/1",
    swagger_offline_docs=True,
)
bootstrapper = FastAPIBootstrapper(bootstrapper_config)
application = bootstrapper.bootstrap()

Read more about available configuration options here: