api endpoints fix and inclusion
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -7,6 +7,9 @@ WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir --upgrade pip \
|
||||
&& pip install --no-cache-dir -r requirements.txt
|
||||
RUN mkdir -p /app/uploads
|
||||
RUN mkdir -p /app/uploads
|
||||
|
||||
|
||||
COPY src ./src
|
||||
COPY alembic.ini ./
|
||||
|
||||
6
services/match/docker-entrypoint.sh.bak.1754801031
Executable file
6
services/match/docker-entrypoint.sh.bak.1754801031
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env sh
|
||||
set -e
|
||||
# Run migrations (no-op if no revisions yet)
|
||||
alembic -c alembic.ini upgrade head || true
|
||||
# Start app
|
||||
exec uvicorn app.main:app --host 0.0.0.0 --port 8000
|
||||
@@ -1,5 +1,5 @@
|
||||
from __future__ import annotations
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.db.session import get_db
|
||||
@@ -23,42 +23,33 @@ def list_pairs(for_user_id: str | None = None, status: str | None = None,
|
||||
_: UserClaims = Depends(get_current_user)):
|
||||
return PairService(db).list(for_user_id=for_user_id, status=status, offset=offset, limit=limit)
|
||||
|
||||
@router.get("/{pair_id}", response_model=PairRead)
|
||||
def get_pair(pair_id: str, db: Session = Depends(get_db), _: UserClaims = Depends(get_current_user)):
|
||||
obj = PairService(db).get(pair_id)
|
||||
if not obj:
|
||||
raise HTTPException(status_code=404, detail="Not found")
|
||||
return obj
|
||||
@router.get("/v1/pairs/{pair_id}", response_model=PairRead)
|
||||
def get_pair(pair_id: UUID, db: Session = Depends(get_db), user: UserClaims = Depends(require_auth)):
|
||||
pair = PairService(db).get(pair_id)
|
||||
if not pair:
|
||||
raise HTTPException(status_code=404, detail="Pair not found")
|
||||
return pair
|
||||
|
||||
@router.patch("/{pair_id}", response_model=PairRead)
|
||||
def update_pair(pair_id: str, payload: PairUpdate, db: Session = Depends(get_db),
|
||||
_: UserClaims = Depends(require_roles("ADMIN","MATCHMAKER"))):
|
||||
svc = PairService(db)
|
||||
obj = svc.get(pair_id)
|
||||
if not obj:
|
||||
raise HTTPException(status_code=404, detail="Not found")
|
||||
return svc.update(obj, **payload.model_dump(exclude_none=True))
|
||||
@router.patch("/v1/pairs/{pair_id}", response_model=PairRead)
|
||||
def update_pair(pair_id: UUID, payload: PairUpdate, db: Session = Depends(get_db), user: UserClaims = Depends(require_admin)):
|
||||
updated = PairService(db).update(pair_id, payload)
|
||||
if not updated:
|
||||
raise HTTPException(status_code=404, detail="Pair not found")
|
||||
return updated
|
||||
|
||||
@router.post("/{pair_id}/accept", response_model=PairRead)
|
||||
def accept(pair_id: str, db: Session = Depends(get_db), user: UserClaims = Depends(get_current_user)):
|
||||
svc = PairService(db)
|
||||
obj = svc.get(pair_id)
|
||||
if not obj:
|
||||
raise HTTPException(status_code=404, detail="Not found")
|
||||
# Validate that current user participates
|
||||
if user.sub not in (str(obj.user_id_a), str(obj.user_id_b)):
|
||||
raise HTTPException(status_code=403, detail="Not allowed")
|
||||
return svc.set_status(obj, "accepted")
|
||||
@router.post("/v1/pairs/{pair_id}/accept", response_model=PairRead)
|
||||
def accept(pair_id: UUID, db: Session = Depends(get_db), user: UserClaims = Depends(require_auth)):
|
||||
res = PairService(db).accept(pair_id, user.sub)
|
||||
if not res:
|
||||
raise HTTPException(status_code=404, detail="Pair not found")
|
||||
return res
|
||||
|
||||
@router.post("/{pair_id}/reject", response_model=PairRead)
|
||||
def reject(pair_id: str, db: Session = Depends(get_db), user: UserClaims = Depends(get_current_user)):
|
||||
svc = PairService(db)
|
||||
obj = svc.get(pair_id)
|
||||
if not obj:
|
||||
raise HTTPException(status_code=404, detail="Not found")
|
||||
if user.sub not in (str(obj.user_id_a), str(obj.user_id_b)):
|
||||
raise HTTPException(status_code=403, detail="Not allowed")
|
||||
return svc.set_status(obj, "rejected")
|
||||
@router.post("/v1/pairs/{pair_id}/reject", response_model=PairRead)
|
||||
def reject(pair_id: UUID, db: Session = Depends(get_db), user: UserClaims = Depends(require_auth)):
|
||||
res = PairService(db).reject(pair_id, user.sub)
|
||||
if not res:
|
||||
raise HTTPException(status_code=404, detail="Pair not found")
|
||||
return res
|
||||
|
||||
@router.delete("/{pair_id}", status_code=204)
|
||||
def delete_pair(pair_id: str, db: Session = Depends(get_db),
|
||||
|
||||
Reference in New Issue
Block a user