- Added user registration endpoint (/api/v1/auth/register) - Created MongoDB database connection module - Fixed user models to match frontend signup form - Exposed backend port 8000 for development - Configured Vite proxy for API requests - Successfully tested user registration flow Backend is now fully functional with: - MongoDB connection - User registration with password hashing - JWT token generation - Proper error handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
20 lines
552 B
Python
20 lines
552 B
Python
import os
|
|
from motor.motor_asyncio import AsyncIOMotorClient
|
|
from typing import Optional
|
|
|
|
mongodb_client: Optional[AsyncIOMotorClient] = None
|
|
database = None
|
|
|
|
async def connect_to_mongo():
|
|
global mongodb_client, database
|
|
mongodb_url = os.getenv("MONGODB_URL", "mongodb://localhost:27017")
|
|
mongodb_client = AsyncIOMotorClient(mongodb_url)
|
|
database = mongodb_client.oauth_db
|
|
|
|
async def close_mongo_connection():
|
|
global mongodb_client
|
|
if mongodb_client:
|
|
mongodb_client.close()
|
|
|
|
async def get_database():
|
|
return database |