File size: 2,333 Bytes
c71e312
b41e915
 
c71e312
 
 
 
 
 
 
 
 
 
 
 
 
b41e915
 
 
 
c71e312
 
b41e915
c71e312
 
 
 
 
 
 
 
 
 
 
 
 
b41e915
c71e312
 
 
 
 
 
 
 
b41e915
c71e312
b41e915
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse  # 👈 nuevo

# routers
from src.expon.iam.interfaces.rest.controllers.auth_controller import router as auth_router
from src.expon.profile.interfaces.rest.controllers.profile_controller import router as profile_router
from src.expon.presentation.interfaces.rest.controllers.presentation_controller import router as presentation_router
from src.expon.feedback.interfaces.rest.feedback_controller import router as feedback_router
from src.expon.subscription.interfaces.rest.controllers.subscription_controller import router as subscription_router
from src.expon.feedback.infrastructure.persistence.jpa.feedback_orm import FeedbackORM
from src.expon.shared.infrastructure.database import Base, engine

app = FastAPI(
    title="Expon Backend API",
    version="1.0.0",
    description="Backend estructurado por bounded contexts con FastAPI",
    docs_url="/docs",            # 👈 habilita /docs
    redoc_url="/redoc",          # 👈 opcional: documentación alternativa
    openapi_url="/openapi.json"  # 👈 necesaria para Swagger
)

# CORS
origins = [
    "https://expon-frontend.netlify.app",
    "http://localhost:4200",
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Rutas principales
app.include_router(auth_router, prefix="/api/v1/auth", tags=["Authentication"])
app.include_router(profile_router, prefix="/api/v1/profile", tags=["Profile"])
app.include_router(presentation_router, prefix="/api/v1/presentation", tags=["Presentations"])
app.include_router(feedback_router, prefix="/api/v1/feedback", tags=["Feedback"])
app.include_router(subscription_router, prefix="/api/v1/subscription", tags=["Subscriptions"])

Base.metadata.create_all(bind=engine)

@app.get("/", response_class=HTMLResponse)
def read_root():
    return """
    <html>
        <head><title>Expon Backend</title></head>
        <body style="font-family: Arial; text-align: center; margin-top: 50px;">
            <h1>✅ ¡Expon backend funcionando con estructura profesional!</h1>
            <p><a href="/docs" style="font-size: 18px; color: #007bff;">Ver documentación Swagger</a></p>
        </body>
    </html>
    """