#!/usr/bin/env bash set -euo pipefail ROUTER="services/profiles/src/app/api/routes/profiles.py" mkdir -p "$(dirname "$ROUTER")" cat > "$ROUTER" <<'PY' from fastapi import APIRouter, Depends, HTTPException, status from sqlalchemy.orm import Session from app.db.deps import get_db from app.core.security import get_current_user, JwtUser from app.schemas.profile import ProfileCreate, ProfileOut from app.repositories.profile_repository import ProfileRepository from app.services.profile_service import ProfileService # отключаем авто-редирект /path -> /path/ router = APIRouter(prefix="/v1/profiles", tags=["profiles"], redirect_slashes=False) @router.get("/me", response_model=ProfileOut) def get_my_profile(current: JwtUser = Depends(get_current_user), db: Session = Depends(get_db)): svc = ProfileService(ProfileRepository(db)) p = svc.get_by_user(current.sub) if not p: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Profile not found") return p @router.post("", response_model=ProfileOut, status_code=status.HTTP_201_CREATED) def create_my_profile(payload: ProfileCreate, current: JwtUser = Depends(get_current_user), db: Session = Depends(get_db)): svc = ProfileService(ProfileRepository(db)) existing = svc.get_by_user(current.sub) if existing: # если хотите строго — верните 409; оставлю 200/201 для удобства e2e return existing return svc.create(current.sub, payload) PY echo "[profiles] rebuilding..." docker compose build profiles docker compose restart profiles