initialize backend with FastAPI and Docker setup

This commit is contained in:
Giovanni committed 2026-06-03 11:35:09 +02:00
1 parent 5d724e37ab
commit 5ff02c0ff5
24 files changed
+420 -243

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session, joinedload
from app.database import get_db
from app.models.project import Project
from app.schemas.project import ProjectCard, ProjectPage
router = APIRouter(prefix="/projects", tags=["Projects"])
@router.get("/", response_model=list[ProjectCard])
def get_projects(db: Session = Depends(get_db)):
return (
db.query(Project)
.options(joinedload(Project.skills))
.all()
)
@router.get("/{project_id}", response_model=ProjectPage)
def get_project(project_id: int, db: Session = Depends(get_db)):
project = (
db.query(Project)
.options(joinedload(Project.skills))
.filter(Project.id == project_id)
.first()
)
if not project:
raise HTTPException(status_code=404, detail="Project not found")
return project