From 444957650686303d7bf878b91d8c66a1e9a56013 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 19 Mar 2025 10:21:56 +0000 Subject: [PATCH] Update code in endpoints/api/v1/endpoint.post.py --- endpoints/api/v1/endpoint.post.py | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 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..89e8501 --- /dev/null +++ b/endpoints/api/v1/endpoint.post.py @@ -0,0 +1,50 @@ +from fastapi import APIRouter, Depends, HTTPException +from core.database import fake_users_db +import uuid +from typing import Optional + +router = APIRouter() + +@router.post("/register") +async def register_user( + username: str, + email: str, + password: str, + full_name: Optional[str] = None +): + """Register new user endpoint""" + if username in fake_users_db: + raise HTTPException(status_code=400, detail="Username already registered") + + if any(user["email"] == 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[username] = { + "id": user_id, + "username": username, + "email": email, + "password": password, + "full_name": full_name, + "disabled": False, + "created_at": str(uuid.uuid1()) + } + + return { + "message": "User registered successfully", + "user": { + "id": user_id, + "username": username, + "email": email, + "full_name": full_name + }, + "next_steps": [ + "Verify your email address", + "Complete your profile", + "Set up two-factor authentication" + ], + "features": { + "rate_limit": 100, + "trial_period_days": 30 + } + } \ No newline at end of file