Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/douaaaaa/jwt-authentication
JWT Authentication with Node.js, Express, and MongoDB
https://github.com/douaaaaa/jwt-authentication
api authentication cookies expressjs javascript jwt mongodb nodejs
Last synced: 8 days ago
JSON representation
JWT Authentication with Node.js, Express, and MongoDB
- Host: GitHub
- URL: https://github.com/douaaaaa/jwt-authentication
- Owner: douaaaaa
- Created: 2024-08-12T14:34:47.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-08-12T15:03:32.000Z (3 months ago)
- Last Synced: 2024-08-13T17:43:14.729Z (3 months ago)
- Topics: api, authentication, cookies, expressjs, javascript, jwt, mongodb, nodejs
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JWT Authentication with Node.js, Express, and MongoDB
### Overview
This project provides a robust authentication system using JSON Web Tokens (JWT) with Node.js, Express, and MongoDB. It allows users to register, log in, log out, and manage their profiles securely.### Features
- User Registration: Create new user accounts.
- User Login: Authenticate users and issue JWTs.
- User Logout: Invalidate the user's session by clearing the JWT.
- Profile Management: Retrieve and update user profile information.### API Endpoints:
- POST /api/user: Register a new user.
- POST /api/user/log-in: Authenticate and log in a user.
- POST /api/user/log-out: End the user session and log out.
- GET /api/user/profile: Retrieve the current user’s profile data.
- PUT /api/user/profile: Update the user’s profile information.### Installation
1. Clone the Repository:
```
git clone https://github.com/douaaaaa/jwt-authentication
```
2. Navigate to the Project Directory:
```
cd jwt-authentication
```
3. Install Dependencies:
```
npm install
```
4. Set Up Environment Variables:
```
MONGO =
PORT =
JWT_SECRET =
```
5. Start the Server:
```
npm run dev
```### Dependencies
- bcryptjs
- cookie-parser
- dotenv
- express
- express-async-handler
- jsonwebtoken
- mongoose