JWT Auth Server implementation in Express.js using Babel and ESLint Airbnb.
Database:
- MongoDB
- Redis
Note: This server is not meant to connect directly with the frontend as you can set the configurations from the API call and this returns all the server errors(if any) in the response.
- First copy/rename
.env.sample
to.env
- Generate one
RS256
key-pair and paste the content in the respective fields of.env
file. Refer this gist - Setup MongoDB and Redis on your machine.
- Install all the NPM dependencies:
npm i
- To watch all the changes in development:
npm start
- To deploy this in production:
npm run production
- Multiple User Roles and Verification
- Sign tokens using Public Key encryption
- Verify tokens using Whitelisting strategy
- Written in modern JavaScript
- ESLint pre-commit hook
- Set dynamic expiration time and subject in the token
-
GET
/users
POST
/users
GET
/users/:id
PUT
/users/:id
DELETE
/users/:id
-
POST
/auth/login
POST
/auth/register
POST
/auth/forgot
POST
/auth/reset/:id
POST
/auth/logout
POST
/auth/verify