feat: project skeleton
- infra (k8s, kind, helm, docker) backbone is implemented - security: implementation + unit tests are done
This commit is contained in:
33
app/main.py
Normal file
33
app/main.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""FastAPI application entry point."""
|
||||
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import AsyncGenerator
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.api.v1 import health
|
||||
from app.config import settings
|
||||
from app.db import db, redis_client
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
"""Manage application lifecycle - connect/disconnect resources."""
|
||||
# Startup
|
||||
await db.connect(settings.database_url)
|
||||
await redis_client.connect(settings.redis_url)
|
||||
yield
|
||||
# Shutdown
|
||||
await redis_client.disconnect()
|
||||
await db.disconnect()
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title="IncidentOps",
|
||||
description="Incident management API with multi-tenant org support",
|
||||
version="0.1.0",
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
# Include routers
|
||||
app.include_router(health.router, prefix=settings.api_v1_prefix, tags=["health"])
|
||||
Reference in New Issue
Block a user