2025-02-19 16:13:10 +01:00

34 lines
944 B
Python

from fastapi import FastAPI, Depends
from fastapi.middleware.cors import CORSMiddleware
from .providers.db_provider import create_db_and_tables
from .routers.houses import router as houses_router
from .routers.owners import router as owners_router
from .middleware.authenticate import authenticate
from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(_app: FastAPI):
create_db_and_tables()
yield
app = FastAPI(
title="Fair Housing API",
description="Provides access to core functionality for the fair housing platform.",
version="1.0.0",
lifespan=lifespan,
dependencies=[Depends(authenticate)],
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(houses_router, prefix="/houses", tags=["houses"])
app.include_router(owners_router, prefix="/owners", tags=["owners"])