2025-03-29 12:27:49 +00:00

22 lines
703 B
Python

from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from core.database import get_db
from models.user import User
from schemas.user import UserCreate, UserResponse
from helpers.user_helpers import create_user
router = APIRouter()
@router.post("/signup", status_code=status.HTTP_201_CREATED, response_model=UserResponse)
async def signup(
user_data: UserCreate,
db: Session = Depends(get_db)
):
"""Create a new user account"""
user = create_user(db=db, user_data=user_data)
if not user:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Unable to create user"
)
return user