Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manthanank/otp-generator
OTP Generator
https://github.com/manthanank/otp-generator
mongodb nodejs nodemailer
Last synced: about 6 hours ago
JSON representation
OTP Generator
- Host: GitHub
- URL: https://github.com/manthanank/otp-generator
- Owner: manthanank
- License: mit
- Created: 2024-02-12T18:41:54.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-13T09:12:27.000Z (9 months ago)
- Last Synced: 2024-02-13T19:56:10.390Z (9 months ago)
- Topics: mongodb, nodejs, nodemailer
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OTP Generator
This is a simple OTP (One Time Password) generator application built using Node.js. It provides functionality to generate and send OTPs via email.
## Installation
Make sure you have Node.js and npm (Node Package Manager) installed on your system.
1. Clone this repository:
```bash
git clone https://github.com/manthanank/otp-generator.git
```2. Navigate into the project directory:
```bash
cd otp-generator
```3. Install dependencies:
```bash
npm install
```## Configuration
Before running the application, you need to set up some configuration variables. Copy the `.env.example` file and rename it to `.env`. Then, update the variables with your own values:
- `PORT`: The port on which the server will run.
- `MONGO_URI`: The URI for your MongoDB database.
- `SMTP_HOST`: SMTP server host.
- `SMTP_PORT`: SMTP server port.
- `SMTP_USER`: SMTP username (usually your email address).
- `SMTP_PASS`: SMTP password.
- `FROM_EMAIL`: Email address from which the OTP emails will be sent.
- `JWT_SECRET`: Secret key for JWT token generation.## Usage
To start the server in development mode with automatic reloading:
```bash
npm run dev
```To start the server in production mode:
```bash
npm start
```## Endpoints
- `POST /generate-otp`: Generates and sends an OTP to the provided email address.
- Request Body:
```json
{
"email": "[email protected]"
}
```- `POST /verify-otp`: Verifies the provided OTP.
- Request Body:
```json
{
"email": "[email protected]",
"otp": "123456"
}
```## Technologies Used
- Node.js
- Express.js
- MongoDB
- Nodemailer
- Randomstring
- Dotenv## License
This project is licensed under the ISC License. See the [LICENSE](LICENSE) file for details.