67 lines
1.5 KiB
Python
67 lines
1.5 KiB
Python
"""
|
|
Main entry point for the Loan Operations API.
|
|
"""
|
|
import sentry_sdk
|
|
from ddtrace import patch_all
|
|
from fastapi import APIRouter, FastAPI
|
|
from sentry_sdk.integrations.fastapi import FastApiIntegration
|
|
|
|
from app.config import settings
|
|
from app.logging import configure_logging, get_logger
|
|
from app.middleware import logging_middleware
|
|
from app.resources import health
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
"""Create and configure the FastAPI application."""
|
|
|
|
# Configure monitoring
|
|
if settings.sentry_dsn:
|
|
sentry_sdk.init(
|
|
dsn=settings.sentry_dsn,
|
|
integrations=[FastApiIntegration()],
|
|
traces_sample_rate=1.0,
|
|
environment=settings.dd_env,
|
|
)
|
|
|
|
if settings.dd_service:
|
|
# Configure Datadog tracing
|
|
patch_all()
|
|
|
|
# Configure logging
|
|
configure_logging()
|
|
logger = get_logger(__name__)
|
|
|
|
# Create FastAPI app
|
|
app = FastAPI(
|
|
title="Loan Operations API",
|
|
description="SBA Loan Operations API",
|
|
version="1.0.0",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
# Include all endpoint routers
|
|
app.include_router(health.router, tags=["health"])
|
|
|
|
return app
|
|
|
|
|
|
def main() -> None:
|
|
"""Run the application."""
|
|
|
|
import uvicorn
|
|
|
|
uvicorn.run(
|
|
app,
|
|
host=settings.host,
|
|
port=settings.port,
|
|
log_level=settings.log_level.lower(),
|
|
reload=settings.debug,
|
|
)
|
|
|
|
app = create_app()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|