This Node.js project provides a system for secure email OTP (One-Time Password) generation, sending, and verification. It is designed for demonstration and learning purposes. It uses Fastify over Express : To focus on speed and efficiency, Fastify is optimized to handle a high volume of requests, making it an ideal choice for performance-critical applications where response time is a key factor.
- OTP Generation: Generates secure, random OTP codes.
- Email Integration: Sends OTPs to users via email. Requires configuration with an email provider (Mailgun is supported).
- OTP Storage & Validation: Securely stores OTPs as hashes in Redis for fast retrieval and validation(Redis is Required).
- Node.js
- npm
- Mailgun account
- Running Redis instance
-
Clone the repository.
-
Install dependencies:
npm install
. -
Create a
.env
file (never committed to version control) with the following fields:MAILGUN_API_KEY=your_mailgun_api_key REDISHOST=your_redis_hostname_or_ip REDISPASSWORD=your_redis_password MAILGUN_DOMAIN=your_mailgun_domain
`node index.js`
`it listen to port localhost:9543` expose port according to your requirement