guarddog_nexus/ ├── core/ scanner, harvester, nexus, llm ├── db/ engine, models, queries ├── routes/ webhooks, api_*, web └── web/ templates + static - 11 файлов перемещено (git mv — сохранена история) - Все импорты обновлены (~15 файлов) - main.py, tests — исправлены пути - 50/50 тестов, ruff clean
63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
"""GuardDog Nexus — FastAPI application entry point."""
|
|
|
|
import os
|
|
from contextlib import asynccontextmanager
|
|
|
|
import uvicorn
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from guarddog_nexus.config import config
|
|
from guarddog_nexus.constants import APP_DESCRIPTION, APP_NAME, APP_PACKAGE, STATIC_MOUNT_PATH
|
|
from guarddog_nexus.db.engine import init_db
|
|
from guarddog_nexus.logging_setup import log
|
|
from guarddog_nexus.routes import api_findings, api_packages, api_scans
|
|
from guarddog_nexus.routes.web import router as web_router
|
|
from guarddog_nexus.routes.webhooks import router as webhook_router
|
|
|
|
STATIC_DIR = os.path.join(os.path.dirname(__file__), "web", "static")
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await init_db()
|
|
log.info("%s started on %s:%s", APP_NAME, config.host, config.port)
|
|
yield
|
|
log.info("%s shutting down", APP_NAME)
|
|
|
|
|
|
app = FastAPI(
|
|
title=APP_NAME,
|
|
version="0.1.0",
|
|
description=APP_DESCRIPTION,
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
app.include_router(webhook_router)
|
|
app.include_router(api_scans.router)
|
|
app.include_router(api_packages.router)
|
|
app.include_router(api_findings.router)
|
|
app.include_router(web_router)
|
|
|
|
if os.path.isdir(STATIC_DIR):
|
|
app.mount(STATIC_MOUNT_PATH, StaticFiles(directory=STATIC_DIR), name="static")
|
|
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "ok", "version": "0.1.0"}
|
|
|
|
|
|
def main():
|
|
uvicorn.run(
|
|
f"{APP_PACKAGE}.main:app",
|
|
host=config.host,
|
|
port=config.port,
|
|
log_level=config.log_level.lower(),
|
|
reload=False,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|