https://github.com/apurva313/email-auth-project
This project is a simple email authentication system built with Node.js, Express, and MongoDB. It allows users to register and verify their email addresses.
https://github.com/apurva313/email-auth-project
email-authentication email-sender express-js mongodb nodejs
Last synced: 3 days ago
JSON representation
This project is a simple email authentication system built with Node.js, Express, and MongoDB. It allows users to register and verify their email addresses.
- Host: GitHub
- URL: https://github.com/apurva313/email-auth-project
- Owner: apurva313
- Created: 2024-05-26T05:24:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-14T10:11:53.000Z (3 months ago)
- Last Synced: 2025-09-11T23:58:19.555Z (26 days ago)
- Topics: email-authentication, email-sender, express-js, mongodb, nodejs
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Email Authentication Project 📧🔒
This project is a simple email authentication system built with Node.js, Express, and MongoDB. It allows users to register and verify their email addresses.
## 🚀 About Me
[](https://www.linkedin.com/apurva313)
[](https://github.com/apurva313)## Project Structure 🗂️
## Installation 🛠️
1. Clone the repository:
```sh
git clone https://github.com/apurva313/Email-auth-Project
```2. Navigate to the project directory:
```sh
cd Email-auth-Project
```3. Install the dependencies:
```sh
npm install
```4. Create a [`.env`](command:_github.copilot.openRelativePath?%5B%7B%22scheme%22%3A%22file%22%2C%22authority%22%3A%22%22%2C%22path%22%3A%22%2FD%3A%2FCode%2FEmail-auth-Project%2F.env%22%2C%22query%22%3A%22%22%2C%22fragment%22%3A%22%22%7D%2C%22b5905f33-9e98-4c82-9582-923b1185c0cf%22%5D "d:\Code\Email-auth-Project\.env") file in the root directory and add the following environment variables:
```env
PORT=
MONGO_URI=
JWT_SECRET=
EMAIL_USER=
EMAIL_PASS=
```## Running the Project 🚀
To start the project, run:
```sh
npm start
```
This will start the server on the port specified in the .env file (default is 3000).## API Endpoints 🌐
### Register 📝
- **URL:** `/api/auth/register`
- **Method:** `POST`
- **Description:** Registers a new user.
- **Request Body:**
```json
{
"email": "apurvakumar@gmail.com",
"password": "password123"
}
```
- **Response:**
- `201 Created` on success
- `400 Bad Request` if the email is already registered or if there are validation errors### Verify Email ✅
- **URL:** `/api/auth/verify-email`
- **Method:** `POST`
- **Description:** Verifies the user's email address.
- **Request Body:**
```json
{
"email": "apurva@gmail.com",
"token": "verification-token"
}
```
- **Response:**
- `200 OK` on success
- `400 Bad Request` if the token is invalid or expired### Code Snippet
```javascript
const express = require('express');
const { register, verifyEmail } = require('../controllers/authController');
const router = express.Router();router.post('/register', register);
router.post('/verify-email', verifyEmail);module.exports = router;
```## Dependencies 📦
- [`express`](https://expressjs.com/): Web framework for Node.js
- [`mongoose`](https://mongoosejs.com/): MongoDB object modeling tool
- [`dotenv`](https://www.npmjs.com/package/dotenv): Loads environment variables from a `.env` file
- [`body-parser`](https://www.npmjs.com/package/body-parser): Middleware for parsing request bodies
- [`bcrypt`](https://www.npmjs.com/package/bcrypt): Library for hashing passwords
- [`jsonwebtoken`](https://www.npmjs.com/package/jsonwebtoken): Library for working with JSON Web Tokens
- [`nodemailer`](https://nodemailer.com/about/): Library for sending emails## Contributing 🤝
We welcome contributions to this project! If you would like to contribute, please follow these steps:
1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Make your changes.
4. Commit your changes (`git commit -m 'Add some feature'`).
5. Push to the branch (`git push origin feature-branch`).
6. Open a pull request.Please make sure to update tests as appropriate.
## License 📄
This project is licensed under the ISC License.