Skip to content

mustafaangi/user-service

Repository files navigation

User Service

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.

Prerequisites

  • Node.js
  • Docker
  • Docker Compose

Environment Variables

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.

Installation

  1. Clone the repository:

    git clone https://github.com/mustafaangi/user-service.git
    cd user-service
  2. Install dependencies:

    npm install

Running the Application

Using Node.js

Start the server:

npm run dev

The server will be running on http://localhost:5001.

Using Docker

Build and run the containers:

docker-compose up --build

The server will be running on http://localhost:5001.

API Endpoints

User Registration

  • URL: /api/users/register

  • Method: POST

  • Content-Type: application/json

  • Body:

    {
      "name": "John Doe",
      "email": "[email protected]",
      "password": "password123"
    }

User Login

  • URL: /api/users/login

  • Method: POST

  • Content-Type: application/json

  • Body:

    {
      "email": "[email protected]",
      "password": "password123"
    }

Running Tests

Run the tests:

npm test

Troubleshooting

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published