Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Verwijderen daos #53

Merged
merged 16 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions backend/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,59 @@
import uvicorn
from fastapi import FastAPI
from starlette import status
from starlette.requests import Request
from starlette.responses import JSONResponse

from routes.projects import projects_router
from routes.subjects import subjects_router
from routes.users import users_router
from db.errors.database_errors import ActionAlreadyPerformedError, ItemNotFoundError
from routes.errors.authentication import InvalidRoleCredentialsError, StudentNotEnrolledError
from routes.project import project_router
from routes.student import student_router
from routes.subject import subject_router
from routes.teacher import teacher_router
from routes.user import users_router

app = FastAPI()

# Koppel routes uit andere modules.
app.include_router(subjects_router, prefix="/api")
app.include_router(student_router, prefix="/api")
app.include_router(teacher_router, prefix="/api")
app.include_router(users_router, prefix="/api")
app.include_router(projects_router, prefix="/api")
app.include_router(project_router, prefix="/api")
app.include_router(subject_router, prefix="/api")


# Koppel de exception handlers
@app.exception_handler(InvalidRoleCredentialsError)
def invalid_admin_credentials_error_handler(request: Request, exc: InvalidRoleCredentialsError) -> JSONResponse:
return JSONResponse(
status_code=status.HTTP_403_FORBIDDEN,
content={"message": exc.ERROR_MESSAGE},
)


@app.exception_handler(ItemNotFoundError)
def item_not_found_error_handler(request: Request, exc: ItemNotFoundError) -> JSONResponse:
return JSONResponse(
status_code=status.HTTP_404_NOT_FOUND,
content={"detail": str(exc)},
)


@app.exception_handler(StudentNotEnrolledError)
def student_already_enrolled_error_handler(request: Request, exc: StudentNotEnrolledError) -> JSONResponse:
return JSONResponse(
status_code=status.HTTP_400_BAD_REQUEST,
content={"detail": str(exc)},
)


@app.exception_handler(ActionAlreadyPerformedError)
def action_already_performed_error_handler(request: Request, exc: ActionAlreadyPerformedError) -> JSONResponse:
return JSONResponse(
status_code=status.HTTP_400_BAD_REQUEST,
content={"detail": str(exc)},
)


if __name__ == "__main__":
uvicorn.run("app:app")
2 changes: 1 addition & 1 deletion backend/db/errors/database_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ def __init__(self, message: str) -> None:
super().__init__(message)


class UniqueConstraintError(Exception):
class ActionAlreadyPerformedError(Exception):
def __init__(self, message: str) -> None:
super().__init__(message)
32 changes: 0 additions & 32 deletions backend/db/implementation/SqlAbstractDAO.py

This file was deleted.

24 changes: 0 additions & 24 deletions backend/db/implementation/SqlAdminDAO.py

This file was deleted.

43 changes: 0 additions & 43 deletions backend/db/implementation/SqlDAOProvider.py

This file was deleted.

69 changes: 0 additions & 69 deletions backend/db/implementation/SqlGroupDAO.py

This file was deleted.

56 changes: 0 additions & 56 deletions backend/db/implementation/SqlProjectDAO.py

This file was deleted.

24 changes: 0 additions & 24 deletions backend/db/implementation/SqlStudentDAO.py

This file was deleted.

Loading