A/C1/C6: Register addresses+audit routers, add seed_default_data in lifespan

This commit is contained in:
2026-07-04 01:30:08 +00:00
parent 4c415e8f37
commit d13f82ae8b
+18 -2
View File
@@ -24,7 +24,9 @@ from app.core.monitoring import record_error, record_request
from app.core.service_container import get_container
from app.plugins.registry import get_registry
from app.routes import (
addresses,
ai_copilot,
audit,
auth,
companies,
contacts,
@@ -157,6 +159,18 @@ async def lifespan(app: FastAPI):
await db.commit()
# Seed default data (EUR currency, 19%/7% tax rates) for all tenants
from app.core.seeds import seed_default_data
async with async_session() as db:
try:
await seed_default_data(db)
await db.commit()
logger.info("Default data seeding completed")
except Exception as exc:
logger.warning(f"Default data seeding failed: {exc}")
await db.rollback()
yield
await close_engine()
@@ -196,8 +210,10 @@ def create_app() -> FastAPI:
app.include_router(sequences.router)
app.include_router(system_settings.router)
app.include_router(attachments.router)
app.include_router(addresses.router)
app.include_router(audit.router)
# ── Register plugin routes (before SPA catch-all) ────────────────
# ── Register plugin routes (before SPA catch-all) ──────────────────
registry = get_registry()
try:
registry.discover_builtins()
@@ -216,7 +232,7 @@ def create_app() -> FastAPI:
except Exception as exc:
logger.warning(f"Plugin discovery failed: {exc}")
# ── Serve frontend static files (SPA) ────────────────────────────
# ── Serve frontend static files (SPA) ──────────────────────────────
# Mount built frontend assets (JS, CSS, images)
frontend_dist = os.path.join(os.path.dirname(__file__), "..", "frontend", "dist")
if os.path.isdir(frontend_dist):