
- User authentication with JWT tokens - Trip management with itineraries - Destination database with search functionality - Booking management for flights, hotels, car rentals, activities - SQLite database with Alembic migrations - Health monitoring endpoint - CORS enabled for all origins - Complete API documentation at /docs and /redoc - Environment variable support for SECRET_KEY Requirements for production: - Set SECRET_KEY environment variable
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api.routes import auth, trips, destinations, bookings
|
|
from app.db.session import engine
|
|
from app.db.base import Base
|
|
|
|
app = FastAPI(
|
|
title="Travel App Backend",
|
|
description="A comprehensive travel planning and booking API",
|
|
version="1.0.0",
|
|
openapi_url="/openapi.json",
|
|
)
|
|
|
|
# CORS configuration
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Create database tables
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
# Include routers
|
|
app.include_router(auth.router, prefix="/auth", tags=["Authentication"])
|
|
app.include_router(trips.router, prefix="/trips", tags=["Trips"])
|
|
app.include_router(destinations.router, prefix="/destinations", tags=["Destinations"])
|
|
app.include_router(bookings.router, prefix="/bookings", tags=["Bookings"])
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"title": "Travel App Backend",
|
|
"documentation": "/docs",
|
|
"health_check": "/health",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {"status": "healthy", "service": "travel-app-backend"}
|