This is a user service application built with Node.js, Express, and MongoDB. It provides user registration and login functionalities, and it uses JWT for authentication. The application is containerized using Docker and Docker Compose.
- Node.js
- Docker
- Docker Compose
Create a .env
file in the root directory and add the following environment variables:
PORT=5001
MONGO_URI=mongodb+srv://<username>:<password>@<cluster-url>/<dbname>?retryWrites=true&w=majority
JWT_SECRET=your_jwt_secret
Replace <username>
, <password>
, <cluster-url>
, and <dbname>
with your actual MongoDB credentials and database name.
-
Clone the repository:
git clone https://github.com/mustafaangi/user-service.git cd user-service
-
Install dependencies:
npm install
Start the server:
npm run dev
The server will be running on http://localhost:5001
.
Build and run the containers:
docker-compose up --build
The server will be running on http://localhost:5001
.
-
URL:
/api/users/register
-
Method:
POST
-
Content-Type:
application/json
-
Body:
{ "name": "John Doe", "email": "[email protected]", "password": "password123" }
-
URL:
/api/users/login
-
Method:
POST
-
Content-Type:
application/json
-
Body:
{ "email": "[email protected]", "password": "password123" }
Run the tests:
npm test
By following these steps and using the provided information, you should be able to successfully run and test your user service application. If you encounter any further issues, please provide specific error messages or logs for additional assistance.