Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/malekd5/jwt-authentication
JWT Authentication is an express project w/ MongoDB (mongoose).
https://github.com/malekd5/jwt-authentication
express jwt mongoose refresh-token
Last synced: about 1 month ago
JSON representation
JWT Authentication is an express project w/ MongoDB (mongoose).
- Host: GitHub
- URL: https://github.com/malekd5/jwt-authentication
- Owner: MalekD5
- Created: 2022-10-21T15:05:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-12T12:07:04.000Z (4 months ago)
- Last Synced: 2024-09-13T23:01:00.890Z (4 months ago)
- Topics: express, jwt, mongoose, refresh-token
- Language: TypeScript
- Homepage:
- Size: 521 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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]([https://www.mongodb.com/atlas/database).
1. clone this repository
```
git clone https://github.com/MalekD5/jwt-authentication.git
```2. install depedencies
```
npm i
```3. 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](https://www.mongodb.com/docs/guides/atlas/connection-string/) to get your mongodb connection string.
4. run `npm run dev` and happy hacking!
# License
This project falls under the MIT license.