WIP checkpoint: Scaffold FastAPI backend project structure

This commit is contained in:
2026-08-17 18:27:26 +00:00
parent 344cbc6b77
commit 5390f66d97
3 changed files with 16 additions and 11 deletions
+9 -5
View File
@@ -13,7 +13,7 @@ from app.models.user import User
router = APIRouter()
# ── Pydantic schemas ────────────────────────────────────────────────
# ── Pydantic schemas ──────────────────────────────────────────────────────────
class UserCreate(BaseModel):
username: str
@@ -35,14 +35,17 @@ class UserUpdate(BaseModel):
is_active: bool | None = None
# ── Endpoints ────────────────────────────────────────────────────────
# ── Endpoints ─────────────────────────────────────────────────────────────────
@router.post(
"/",
response_model=UserResponse,
status_code=status.HTTP_201_CREATED,
)
async def create_user(user_in: UserCreate, db: Annotated[AsyncSession, Depends(get_db)]):
async def create_user(
user_in: UserCreate,
db: Annotated[AsyncSession, Depends(get_db)],
):
"""Register a new user."""
# Check uniqueness of username
existing = await db.execute(select(User).where(User.username == user_in.username))
@@ -54,8 +57,9 @@ async def create_user(user_in: UserCreate, db: Annotated[AsyncSession, Depends(g
if existing.scalar_one_or_none():
raise HTTPException(status_code=400, detail="Email already registered")
from app.routers.auth import hash_password
hashed = hash_password(user_in.password)
from app.routers.auth import _get_password_hash
hashed = _get_password_hash(user_in.password)
user = User(
username=user_in.username,