/nodejs-redis-mongo-k8s

Nodejs based authentication mechanism. It can be run on Docker, Kubernetes, AWS Lambda

Primary LanguageJavaScriptMIT LicenseMIT

Welcome to nodejs-authentication 👋

version Build Status dependencies Status License: MIT

nodejs-authentication is Nodejs based authentication mechanism. Users can register, login, logout, and display user profiles. The security mechanism is implemented with access tokens. Redis is responsible for holding these access tokens. When the user logged in to the system successfully, the application generates a secure access token and write to Redis with the user's data. After that application verifies the user's identity by using Redis. This increases application performance significantly.

diagram


Install

  1. First of all, you have to install and start Redis Server and MongoDB on your computer. You can also use MongoDB Atlas which is a MongoDB cloud service instead of installing MongoDB to your computer.

  2. Then install the application dependencies using the following command

npm install

Usage

  • Application can be directly run using the following command, you can access the application from port 8080.
npm run development
  • Application can be run in the Docker container using the following command. Type the command in the application root folder to the terminal. Of course docker daemon must be running. This command creates and runs three containers. One for authentication application, one for Redis and one for MongoDB. These containers communicate with each other. You can access the authentication application using port 8080 from your host operating system. Moreover, you can connect Redis and MongoDB containers to manage and display data from port 6379 and 27017 respectively.
docker-compose up
  • Also, the application can be run on the Serverless Architecture. Upload project to AWS Lambda. Then it is ready to handle requests. However, you have to configure Redis and MongoDB using other AWS Services by yourself. Assign the Lambda handler as shown below.
src/serverless.handler

Run tests

npm test

Author

👤 Ahmet Batur Tülek

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator