Endpoint
This is a public endpoint that does not require authentication.
Request Body
The full name of the user
A valid email address. Must be unique in the system.
The user’s password. Will be hashed using bcrypt with 10 salt rounds.
Validation Rules
The registration endpoint performs the following validations:Required Fields Check
All three fields (name, email, password) must be provided. Missing fields result in a 400 error.
Email Uniqueness
The email must not already exist in the database. Duplicate emails return a 400 error.
Request Example
Response
Success message confirming user registration
Success Response (201 Created)
Error Responses
400 Bad Request - Missing Fields
400 Bad Request - Missing Fields
Returned when required fields are not provided.Cause: One or more required fields (name, email, password) are missing from the request body.
400 Bad Request - Email Already Exists
400 Bad Request - Email Already Exists
Returned when the email is already registered in the system.Cause: A user with this email address already exists in the database.
500 Internal Server Error
500 Internal Server Error
Returned when an unexpected server error occurs.Cause: Database connection issues or other server-side errors.
Implementation Details
The registration endpoint is implemented in theauthController.js file:
The implementation is located at
src/controllers/authController.js:9 in the source repository.Security Considerations
Bcrypt Hashing Process
The registration process uses bcrypt to hash passwords:- Adaptive hashing: Computational cost can be increased over time
- Salt generation: Automatic random salt for each password
- Collision resistant: One-way function that cannot be reversed
Database Schema
The user record is stored in theusers table with the following structure:
| Column | Type | Description |
|---|---|---|
| id | INTEGER | Auto-incrementing primary key |
| name | VARCHAR | User’s full name |
| VARCHAR | Unique email address | |
| password | VARCHAR | Bcrypt hashed password |
Next Steps
After successful registration, users can authenticate using the login endpoint:Login
Learn how to authenticate and receive a JWT token