35 lines
989 B
Python
35 lines
989 B
Python
from fastapi import FastAPI, Depends
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from .providers.db_provider import create_db_and_tables, startup_migrations
|
|
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):
|
|
startup_migrations()
|
|
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"])
|