MalekD5 / jwt-authentication

JWT Authentication is an express project w/ MongoDB (mongoose).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JWT Authentication (Typescript)

JWT Authentication is an express project w/ MongoDB (mongoose). This project was built as PoC for a blog backend.

Features:

  • JWT Authentication w/ Refresh Token.

  • Protected routes for only authenticated users.

  • Role Based routes protection for specific roles.

  • auth, logout, refresh, and register routes.

  • httpOnly and secure cookies.

  • Async CRUD operations using mongoose.

Compiling

This project requires to have Mongo database. get your free database from MongoDB Atlas.

  1. clone this repository
git clone https://github.com/MalekD5/jwt-authentication.git
  1. install depedencies
npm i
  1. add your environmental variable to your .env file
MONGODB_URL=
ACCESS_TOKEN_SECRET=
REFRESH_TOKEN_SECRET=

the ACCESS_TOKEN_SECRET and REFRESH_TOKEN_SECRET can be anything. for MONGODB_URL if you are using atlas, follow this tutorial to get your mongodb connection string.

  1. run npm run dev and happy hacking!

License

This project falls under the MIT license.

About

JWT Authentication is an express project w/ MongoDB (mongoose).


Languages

Language:TypeScript 100.0%