Initial InfraPulse scaffold

This commit is contained in:
Keith Smith
2026-05-22 17:36:40 -06:00
commit a707186a5e
92 changed files with 6918 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
from contextlib import asynccontextmanager
from collections.abc import AsyncIterator
import logging
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from sqlalchemy.exc import SQLAlchemyError
from app.api import alerts, assets, auth, health, monitors, notifications
from app.core.config import settings
from app.db.session import SessionLocal
from app.services.bootstrap import ensure_initial_admin
logger = logging.getLogger(__name__)
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncIterator[None]:
try:
with SessionLocal() as db:
ensure_initial_admin(db)
except SQLAlchemyError as exc:
logger.warning("Initial admin bootstrap skipped because the database is unavailable: %s", exc)
yield
app = FastAPI(
title="InfraPulse API",
version="0.1.0",
description="Self-hosted infrastructure monitoring API",
lifespan=lifespan,
)
app.add_middleware(
CORSMiddleware,
allow_origins=[str(settings.frontend_url)],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(health.router)
app.include_router(auth.router)
app.include_router(assets.router)
app.include_router(monitors.router)
app.include_router(alerts.router)
app.include_router(notifications.router)