40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
"""Polaris FastAPI application.
|
|
|
|
CORS allow-all (MVP). Routers mounted under /api exactly as the contract lists.
|
|
"""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.database import Base, engine
|
|
from app.routers import admin, analytics, auth, customers, health, orders, products, suppliers, webhooks
|
|
from app.version import VERSION
|
|
|
|
# Idempotent — schema.sql is canonical and already applied; create_all only
|
|
# creates anything missing.
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(title="Polaris API", version=VERSION)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(health.router, prefix="/api", tags=["health"])
|
|
app.include_router(auth.router, prefix="/api/auth", tags=["auth"])
|
|
app.include_router(products.router, prefix="/api/products", tags=["products"])
|
|
app.include_router(suppliers.router, prefix="/api/suppliers", tags=["suppliers"])
|
|
app.include_router(orders.router, prefix="/api/orders", tags=["orders"])
|
|
app.include_router(customers.router, prefix="/api/customers", tags=["customers"])
|
|
app.include_router(admin.router, prefix="/api/admin", tags=["admin"])
|
|
app.include_router(analytics.router, prefix="/api/analytics", tags=["analytics"])
|
|
app.include_router(webhooks.router, prefix="/api/webhooks", tags=["webhooks"])
|
|
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {"app": "polaris", "version": VERSION, "docs": "/docs"}
|