feat: add FastAPI backend with PostgreSQL and start script fixes
- Add server/ directory with FastAPI backend - Fix server/start.sh to properly handle venv on Windows/Git Bash - Add alembic migrations and pyproject.toml - Add server tests Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
31
server/src/app/api/v1/endpoints/reimbursements.py
Normal file
31
server/src/app/api/v1/endpoints/reimbursements.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_db
|
||||
from app.schemas.reimbursement import ReimbursementCreate, ReimbursementRead
|
||||
from app.services.reimbursement import ReimbursementService
|
||||
|
||||
router = APIRouter()
|
||||
DbSession = Annotated[Session, Depends(get_db)]
|
||||
|
||||
|
||||
@router.get("", response_model=list[ReimbursementRead])
|
||||
def list_reimbursements(db: DbSession) -> list[ReimbursementRead]:
|
||||
return ReimbursementService(db).list_reimbursements()
|
||||
|
||||
|
||||
@router.post("", response_model=ReimbursementRead, status_code=status.HTTP_201_CREATED)
|
||||
def create_reimbursement(payload: ReimbursementCreate, db: DbSession) -> ReimbursementRead:
|
||||
return ReimbursementService(db).create_reimbursement(payload)
|
||||
|
||||
|
||||
@router.get("/{request_id}", response_model=ReimbursementRead)
|
||||
def get_reimbursement(request_id: str, db: DbSession) -> ReimbursementRead:
|
||||
request = ReimbursementService(db).get_reimbursement(request_id)
|
||||
if request is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Request not found")
|
||||
return request
|
||||
Reference in New Issue
Block a user