- Added RoleRepository and UserRepository for managing roles and users. - Implemented methods for creating, retrieving, and assigning roles to users. - Introduced functions to ensure default roles and an admin user exist in the system. - Updated UnitOfWork to include user and role repositories. - Created new security module for password hashing and JWT token management. - Added tests for authentication flows, including registration, login, and password reset. - Enhanced HTML templates for user registration, login, and password management with error handling. - Added a logo image to the static assets.
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
from typing import Awaitable, Callable
|
|
|
|
from fastapi import FastAPI, Request, Response
|
|
from fastapi.staticfiles import StaticFiles
|
|
from middleware.validation import validate_json
|
|
from config.database import Base, engine
|
|
from models import (
|
|
FinancialInput,
|
|
Project,
|
|
Scenario,
|
|
SimulationParameter,
|
|
)
|
|
from routes.auth import router as auth_router
|
|
from routes.dashboard import router as dashboard_router
|
|
from routes.projects import router as projects_router
|
|
from routes.scenarios import router as scenarios_router
|
|
|
|
# Initialize database schema (imports above ensure models are registered)
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.middleware("http")
|
|
async def json_validation(
|
|
request: Request, call_next: Callable[[Request], Awaitable[Response]]
|
|
) -> Response:
|
|
return await validate_json(request, call_next)
|
|
|
|
|
|
@app.get("/health", summary="Container health probe")
|
|
async def health() -> dict[str, str]:
|
|
return {"status": "ok"}
|
|
|
|
|
|
app.include_router(dashboard_router)
|
|
app.include_router(auth_router)
|
|
app.include_router(projects_router)
|
|
app.include_router(scenarios_router)
|
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|