From f4682f15509b3c5cab59574ac8f3f720571856b6 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 18 Mar 2025 15:39:42 +0000 Subject: [PATCH] Update code in endpoints/api/v1/endpoint.post.py --- endpoints/api/v1/endpoint.post.py | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 endpoints/api/v1/endpoint.post.py diff --git a/endpoints/api/v1/endpoint.post.py b/endpoints/api/v1/endpoint.post.py new file mode 100644 index 0000000..1bb640e --- /dev/null +++ b/endpoints/api/v1/endpoint.post.py @@ -0,0 +1,46 @@ +from fastapi import APIRouter, Depends, HTTPException +from core.database import fake_users_db +from pydantic import BaseModel, EmailStr +import uuid + +router = APIRouter() + +class RegistrationData(BaseModel): + username: str + email: EmailStr + password: str + full_name: str + +@router.post("/register") +async def register_user(data: RegistrationData): + """Register new user endpoint""" + if data.username in fake_users_db: + raise HTTPException(status_code=400, detail="Username already exists") + + if any(user["email"] == data.email for user in fake_users_db.values()): + raise HTTPException(status_code=400, detail="Email already registered") + + user_id = str(uuid.uuid4()) + fake_users_db[data.username] = { + "id": user_id, + "email": data.email, + "password": data.password, + "full_name": data.full_name, + "disabled": False, + "created_at": str(uuid.uuid1()) + } + + return { + "message": "Registration successful", + "user_id": user_id, + "username": data.username, + "next_steps": [ + "Verify your email address", + "Complete your profile", + "Set up two-factor authentication" + ], + "features": { + "rate_limit": 50, + "expires_in": 3600 + } + } \ No newline at end of file