User registration endpoint with comprehensive validation and security measures.
/api/auth/registerCreates a new user account with the provided credentials and personal information.
Content-Type{
"name": "string (required, min: 2 characters)",
"email": "string (required, valid email format)",
"password": "string (required, min: 6 characters)"
}const response = await fetch('/api/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'John Doe',
email: 'john.doe@example.com',
password: 'securepassword123'
})
});{
"success": true,
"message": "Account created successfully",
"user": {
"id": "string",
"name": "John Doe",
"email": "john.doe@example.com",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
}
}{
"error": "All fields are required"
}Other validation errors: "Invalid email format", "Password must be at least 6 characters long", "Name must be at least 2 characters long"
{
"error": "An account with this email already exists"
}{
"error": "Failed to create user account"
}