major refactoring adding vendor and customer features
This commit is contained in:
38
main.py
38
main.py
@@ -1,18 +1,22 @@
|
||||
# main.py
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from fastapi import Depends, FastAPI, HTTPException
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.main import api_router
|
||||
from app.routes.frontend import router as frontend_router
|
||||
from app.core.config import settings
|
||||
from app.core.database import get_db
|
||||
from app.core.lifespan import lifespan
|
||||
from app.exceptions.handler import setup_exception_handlers
|
||||
from app.exceptions import ServiceUnavailableException
|
||||
from middleware.vendor_context import vendor_context_middleware
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -36,12 +40,20 @@ app.add_middleware(
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Include API router
|
||||
app.include_router(api_router, prefix="/api/v1")
|
||||
# Add vendor context middleware (ADDED - must be after CORS)
|
||||
app.middleware("http")(vendor_context_middleware)
|
||||
|
||||
# ========================================
|
||||
# MOUNT STATIC FILES - ADD THIS SECTION
|
||||
# ========================================
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
# ========================================
|
||||
|
||||
# Include API router
|
||||
app.include_router(api_router, prefix="/api")
|
||||
app.include_router(frontend_router)
|
||||
|
||||
# Public Routes (no authentication required)
|
||||
# Core application endpoints (Public Routes, no authentication required)
|
||||
@app.get("/", include_in_schema=False)
|
||||
async def root():
|
||||
"""Redirect root to documentation"""
|
||||
@@ -65,14 +77,20 @@ def health_check(db: Session = Depends(get_db)):
|
||||
"complete": "/documentation",
|
||||
},
|
||||
"features": [
|
||||
"JWT Authentication",
|
||||
"Marketplace-aware product import",
|
||||
"Multi-vendor product management",
|
||||
"Stock management with location tracking",
|
||||
"Multi-tenant architecture with vendor isolation",
|
||||
"JWT Authentication with role-based access control",
|
||||
"Marketplace product import and curation",
|
||||
"Vendor catalog management",
|
||||
"Product-based inventory tracking",
|
||||
"Stripe Connect payment processing",
|
||||
],
|
||||
"supported_marketplaces": [
|
||||
"Letzshop",
|
||||
],
|
||||
"deployment_modes": [
|
||||
"Subdomain-based (production): vendor.platform.com",
|
||||
"Path-based (development): /vendor/vendorname/",
|
||||
],
|
||||
"auth_required": "Most endpoints require Bearer token authentication",
|
||||
}
|
||||
except Exception as e:
|
||||
@@ -80,18 +98,14 @@ def health_check(db: Session = Depends(get_db)):
|
||||
raise ServiceUnavailableException("Service unhealthy")
|
||||
|
||||
|
||||
# Documentation redirect endpoints
|
||||
@app.get("/documentation", response_class=HTMLResponse, include_in_schema=False)
|
||||
async def documentation():
|
||||
"""Redirect to MkDocs documentation"""
|
||||
# Development
|
||||
"""Redirect to documentation"""
|
||||
if settings.debug:
|
||||
return RedirectResponse(url="http://localhost:8001")
|
||||
# Production
|
||||
return RedirectResponse(url=settings.documentation_url)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
|
||||
|
||||
Reference in New Issue
Block a user