fids/gateway/src/api/main.py

41 lines
1.4 KiB
Python

import logging
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from logmiddleware import RouterLoggingMiddleware, logging_config
from src.api.config import API_DEBUG
from src.api.routes import auth, flights, health, notifications, subscriptions, users
logging.config.dictConfig(logging_config)
logger = logging.getLogger(__name__)
app = FastAPI(title="Flights Information API")
app.include_router(flights.router, prefix="/flights")
app.include_router(health.router, prefix="/health")
app.include_router(auth.router, prefix="/auth")
app.include_router(users.router, prefix="/users")
app.include_router(subscriptions.router, prefix="/subscriptions")
app.include_router(notifications.router, prefix="/notifications")
app.add_middleware(
CORSMiddleware,
allow_origins=[
"https://fids.slc.ar",
"https://airport.fids.slc.ar",
"http://localhost:8080",
"http://localhost:8081",
"http://localhost:8000",
"http://localhost:8001",
"http://host.docker.internal:8000",
"http://host.docker.internal:8001",
"http://localhost:3000",
"http://192.168.1.127:3000",
],
allow_credentials=True,
allow_methods=["POST", "GET", "PUT", "DELETE", "OPTIONS", "PATCH"],
allow_headers=["*"],
expose_headers=["x-count"],
)
app.add_middleware(RouterLoggingMiddleware, logger=logger, api_debug=API_DEBUG)