This is a backend API built with Node.js, Express, and MongoDB. It provides user registration functionality with validation and password hashing.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install the dependencies:
npm install
-
Create a
.env
file in the root directory and add your environment variables (see below).
-
Start the server:
npm start
-
The server will run on
http://localhost:3000
.
- POST
/users/register
- Request Body:
{ "fullname": { "fname": "John", "lname": "Doe" }, "email": "[email protected]", "password": "yourpassword" }
- Response:
- On success: Returns user data and authentication token.
- On error: Returns validation errors.
- Request Body:
- POST
/users/login
- Request Body:
{ "email": "[email protected]", "password": "yourpassword" }
- Response:
- On success: Returns authentication token and user data.
- On error: Returns validation errors or invalid credentials message.
- Request Body:
- GET
/users/logout
- Response:
- On success: Returns a message indicating the user has logged out.
- On error: Returns unauthorized status if the user is not authenticated.
- Response:
- GET
/users/profile
This endpoint retrieves the authenticated user's profile information.
- Authorization: Bearer token (required)
-
200 OK: Returns the user's profile information.
{ "_id": "user_id", "email": "[email protected]", "fullname": { "fname": "First Name", "lname": "Last Name" }, }
-
401 Unauthorized: If the user is not authenticated.
-
500 Internal Server Error: If there is an error retrieving the user information.
- POST
/captains/register
- Request Body:
{ "fullname": { "fname": "John", "lname": "Doe" }, "email": "[email protected]", "password": "yourpassword", "vehicle": { "color": "red", "plate": "ABC123", "capacity": 4, "type": "car" }, "status": "active", "location": { "ltd": 12.34, "lang": 56.78 } }
- Response:
- On success: Returns the newly created captain data.
- On error: Returns validation errors or existing captain message.
- Request Body:
- POST
/captains/login
- Request Body:
{ "email": "[email protected]", "password": "yourpassword" }
- Response:
- On success: Returns authentication token and captain data.
- On error: Returns validation errors or invalid credentials message.
- Request Body:
- GET
/captains/profile
- Response:
- 200 OK: Returns the captain's profile information.
- 401 Unauthorized: If the captain is not authenticated.
- Response:
- GET
/captains/logout
- Response:
- On success: Returns a message indicating the captain has logged out.
- On error: Returns unauthorized status if the captain is not authenticated.
- Response:
DB_CONNECTION
: MongoDB connection string.TOKEN_SECRET
: Secret key for JWT signing.
This project demonstrates a full-stack application with a React frontend and a Node.js backend. The backend API provides endpoints for user and captain registration, login, profile management, and logout. The frontend, built with React and Vite, interacts with these endpoints to provide a seamless user experience. By following the installation and usage instructions, you can set up and run this project locally to explore its features and functionality.
This is the frontend application built with React and Vite. It provides the user interface for the Uber clone application.
- Clone the repository:
git clone <repository-url> cd <repository-directory>/Frontend