90 lines
3.9 KiB
Python
90 lines
3.9 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.config import settings
|
|
from app.core.exceptions import register_exception_handlers
|
|
from app.core.middleware import TierMiddleware, QuotaMiddleware, RateLimitMiddleware
|
|
import logging
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
try:
|
|
import sentry_sdk
|
|
from sentry_sdk.integrations.fastapi import FastApiIntegration
|
|
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
|
|
|
|
sentry_sdk.init(
|
|
dsn=settings.SENTRY_DSN,
|
|
traces_sample_rate=0.1,
|
|
environment="production" if not settings.DEBUG else "development",
|
|
integrations=[
|
|
FastApiIntegration(),
|
|
SqlalchemyIntegration(),
|
|
],
|
|
)
|
|
logger.info("Sentry initialized")
|
|
except (ImportError, Exception) as e:
|
|
logger.info(f"Sentry not configured: {e}")
|
|
|
|
app = FastAPI(
|
|
title=settings.APP_NAME,
|
|
version="1.0.0",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
debug=settings.DEBUG,
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[settings.FRONTEND_URL],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.add_middleware(RateLimitMiddleware)
|
|
app.add_middleware(QuotaMiddleware)
|
|
app.add_middleware(TierMiddleware)
|
|
|
|
register_exception_handlers(app)
|
|
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "ok", "app": settings.APP_NAME, "version": "1.0.0"}
|
|
|
|
|
|
from app.api.v1 import auth, marketing, translate, customer, quotation, whatsapp, product, exchange, push, admin, analytics, teams, onboarding, notification, feedback, payment, interaction, silent_pattern, training, followup, ai_assistant, discovery, certification, invoice
|
|
|
|
app.include_router(auth.router, prefix="/api/v1/auth", tags=["auth"])
|
|
app.include_router(marketing.router, prefix="/api/v1/marketing", tags=["marketing"])
|
|
app.include_router(translate.router, prefix="/api/v1/translate", tags=["translate"])
|
|
app.include_router(translate.public_router, prefix="/api/v1/translate/public", tags=["translate-public"])
|
|
app.include_router(customer.router, prefix="/api/v1/customers", tags=["customers"])
|
|
app.include_router(quotation.router, prefix="/api/v1/quotations", tags=["quotations"])
|
|
app.include_router(whatsapp.router, prefix="/api/v1/whatsapp", tags=["whatsapp"])
|
|
app.include_router(product.router, prefix="/api/v1/products", tags=["products"])
|
|
app.include_router(exchange.router, prefix="/api/v1/exchange", tags=["exchange"])
|
|
app.include_router(push.router, prefix="/api/v1/push", tags=["push"])
|
|
app.include_router(admin.router, prefix="/api/v1/admin", tags=["admin"])
|
|
app.include_router(analytics.router, prefix="/api/v1/analytics", tags=["analytics"])
|
|
app.include_router(teams.router, prefix="/api/v1/teams", tags=["teams"])
|
|
app.include_router(onboarding.router, prefix="/api/v1/onboarding", tags=["onboarding"])
|
|
app.include_router(notification.router, prefix="/api/v1/notifications", tags=["notifications"])
|
|
app.include_router(feedback.router, prefix="/api/v1/feedback", tags=["feedback"])
|
|
app.include_router(payment.router, prefix="/api/v1/payment", tags=["payment"])
|
|
app.include_router(interaction.router, prefix="/api/v1/interaction", tags=["interaction"])
|
|
app.include_router(silent_pattern.router, prefix="/api/v1/silent-pattern", tags=["silent-pattern"])
|
|
app.include_router(training.router, prefix="/api/v1/training", tags=["training"])
|
|
app.include_router(followup.router, prefix="/api/v1/followup", tags=["followup"])
|
|
app.include_router(ai_assistant.router, prefix="/api/v1/ai", tags=["ai-assistant"])
|
|
app.include_router(discovery.router, prefix="/api/v1/discovery", tags=["discovery"])
|
|
app.include_router(certification.router, prefix="/api/v1/certification", tags=["certification"])
|
|
app.include_router(invoice.router, prefix="/api/v1/invoices", tags=["invoices"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run("app.main:app", host="0.0.0.0", port=8000, reload=True)
|