Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Latest commit

 

History

History
61 lines (34 loc) · 2.03 KB

README.md

File metadata and controls

61 lines (34 loc) · 2.03 KB

License

Express-JWT-API

A stateless and scalable RESTful Api utilizing JWT authorization, MongoDB, Docker deployment, HaProxy loadbalancing, and more.

Foreword

I created this initially as a learning platform to pick up JWT and stateless authentication however because of how useful it eventually became i decided to post it on a repo to share as a scalable JWT example/boilerplate in express. Do note this should not be used in production as it does not support TLS and a few other things. This is soley an example of JWT in action on an express API.

Features

  • Stateless authentication with JWT allowing for easy horizontal scaling
  • Docker containerization for easy deployment of the full system
  • HaProxy loadbalancing for a simple load balancer for our api cluster
  • Clean and effective code following StandardJS
  • MongoDB Databasing

REST API

Config located in /Rest-Api/src/settings/settings.json. (Storing sensative info in a .env is preferable, for this example i keep everything in a json file)

Setting ignored_routes are all the routes which dont require authentication (public).

To authenticate client must pass provided Bearer token in the header and decoded payload will be on the request object. See more here

Endpoints

GET /

GET /healthcheck

GET /auth

POST /auth/register

body form data:

  • username<String> - Must be 3-32 characters

  • password<String> - Must be 5-100 characters

Returns Success OR Error

POST /auth/login

body form data:

  • username<String> - Must be 3-32 characters

  • password<String> - Must be 5-100 characters

Returns Success (Including AUTH<Bearer> Token) OR Error

Infrastructure

  • MongoDB (Required)
  • HaProxy (Optional)
  • Docker & Docker-Compose (Optional)

GitHub followers