55 lines
1.2 KiB
Python
55 lines
1.2 KiB
Python
"""
|
|
Main entry point for the Loan Operations API.
|
|
"""
|
|
import uvicorn
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.core.config import settings
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
"""Create and configure the FastAPI application."""
|
|
|
|
app = FastAPI(
|
|
title=settings.api_title,
|
|
description=settings.api_description,
|
|
version=settings.api_version,
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
# Add CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.allowed_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Health check endpoint
|
|
@app.get("/health-check")
|
|
async def health_check():
|
|
"""Health check endpoint."""
|
|
return {"status": "healthy", "service": "loapi"}
|
|
|
|
return app
|
|
|
|
|
|
def main():
|
|
"""Run the application."""
|
|
app = create_app()
|
|
|
|
uvicorn.run(
|
|
app,
|
|
host=settings.host,
|
|
port=settings.port,
|
|
log_level=settings.log_level.lower(),
|
|
reload=settings.debug,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|