Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gourabofficial/mern-auth
MERN Authentication .
https://github.com/gourabofficial/mern-auth
cors jwt-authentication nodejs react
Last synced: about 6 hours ago
JSON representation
MERN Authentication .
- Host: GitHub
- URL: https://github.com/gourabofficial/mern-auth
- Owner: gourabofficial
- Created: 2025-02-09T19:45:11.000Z (2 days ago)
- Default Branch: main
- Last Pushed: 2025-02-10T17:04:49.000Z (about 24 hours ago)
- Last Synced: 2025-02-10T18:22:43.867Z (about 23 hours ago)
- Topics: cors, jwt-authentication, nodejs, react
- Language: JavaScript
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# MERN Authentication
This is a MERN (MongoDB, Express, React, Node.js) stack application for user authentication.
## Features
- User registration
- User login
- User logout
- JWT-based authentication
- Password hashing with bcrypt
- Environment variable configuration## Prerequisites
- Node.js
- MongoDB
- npm or yarn## Installation
1. Clone the repository:
```bash
git clone https://github.com/yourusername/MERN-Auth.git
cd MERN-Auth
```2. Install dependencies:
```bash
npm install
```or
```bash
yarn install
```3. Create a `.env` file in the root directory and add the following environment variables:
```plaintext
MONGODB_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret
NODE_ENV=development
```4. Start the server:
```bash
npm start
```or
```bash
yarn start
```## API Endpoints
### Register
- **URL:** `/api/auth/register`
- **Method:** `POST`
- **Body:**
```json
{
"name": "John Doe",
"email": "[email protected]",
"password": "password123"
}
```
- **Response:**
```json
{
"success": true,
"message": "User Registered Successfully"
}
```### Login
- **URL:** `/api/auth/login`
- **Method:** `POST`
- **Body:**
```json
{
"email": "[email protected]",
"password": "password123"
}
```
- **Response:**
```json
{
"success": true,
"message": "User Logged in Successfully"
}
```### Logout
- **URL:** `/api/auth/logout`
- **Method:** `POST`
- **Response:**
```json
{
"success": true,
"message": "Logged out Successfully"
}
```## License
This project is licensed under the MIT License.