62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
import sys
|
|
import os
|
|
|
|
# Add the backend directory to the Python path so imports work when running from app directory
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.core.config import settings
|
|
from app.api import auth, contacts, lists, templates, campaigns, imports, google, webhooks, stats, workers
|
|
import logging
|
|
import uvicorn
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
)
|
|
|
|
app = FastAPI(
|
|
title="WhatsApp Campaign Manager API",
|
|
description="Production-quality API for managing WhatsApp campaigns with compliance",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# CORS
|
|
cors_origins = list({*settings.cors_origins_list, "http://localhost:5173"})
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=cors_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(auth.router, prefix="/api/auth", tags=["Authentication"])
|
|
app.include_router(contacts.router, prefix="/api/contacts", tags=["Contacts"])
|
|
app.include_router(lists.router, prefix="/api/lists", tags=["Lists"])
|
|
app.include_router(templates.router, prefix="/api/templates", tags=["Templates"])
|
|
app.include_router(campaigns.router, prefix="/api/campaigns", tags=["Campaigns"])
|
|
app.include_router(imports.router, prefix="/api/imports", tags=["Imports"])
|
|
app.include_router(google.router, prefix="/api/imports", tags=["Google OAuth"])
|
|
app.include_router(webhooks.router, prefix="/api/webhooks", tags=["Webhooks"])
|
|
app.include_router(stats.router, prefix="/api/stats", tags=["Statistics"])
|
|
app.include_router(workers.router, prefix="/api/workers", tags=["Workers"])
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {
|
|
"name": "WhatsApp Campaign Manager API",
|
|
"version": "1.0.0",
|
|
"status": "running"
|
|
}
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
return {"status": "healthy"}
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(app, host="127.0.0.1", port=8000, reload=False)
|