Skip to content

Notezz Backend - API Authentication using JWT's (JSON Web Tokens). MVC pattern

Notifications You must be signed in to change notification settings

biswa-rx/notezz-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notezz Backend

This is an API using JWT's that you can plug inside your current project or you can start with a new one. Email & Password is used for authentication.

The API based on Node.js, Express, MongoDB & Redis, following the MVC pattern i.e. Model View Controller.

It only access the user when that user have authrised access token which he/she can generate through via resister or login.

In this API a authorised user can GET,POST,PATCH and DELETE on his notes only.

Mongoose is used for storing Users in Database. Redis is used for storing Refresh Tokens - to validate them as well at the same time Blacklisting them.

The application is production ready.


To start setting up the project

Step 1: Clone the repo

git clone https://github.com/biswa-rx/notezz-backend.git

Step 2: cd into the cloned repo and run:

npm install

Step 3: Put your credentials in the .env file.

PORT=3000
MONGODB_URI=mongodb://localhost:27017
DB_NAME=YOUR_DB_NAME
ACCESS_TOKEN_SECRET=GENERATE_FROM_GENERATE_KEYS_FILE_IN_HELPER
REFRESH_TOKEN_SECRET=GENERATE_FROM_GENERATE_KEYS_FILE_IN_HELPER

Step 4: To generate 256-bit keys for JWT

node ./helpers/generate_keys.js

Step 5: Install Redis (Linux Ubuntu)

sudo apt-get install redis-server

Step 6: Run Redis Server (Linux Ubuntu)

redis-server

Step 7: Install MongoDB (Linux Ubuntu)

See https://docs.mongodb.com/manual/installation/ for more infos

Step 8: Run Mongo daemon

sudo service mongod start

Step 9: Start the API by

npm start

Step 10 (Optional): Change the expiration time of Access Token and Refresh Token according to your needs by going inside the ./helpers/jwt_helper.js file.

Author

About

Notezz Backend - API Authentication using JWT's (JSON Web Tokens). MVC pattern

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published