This project aims to demonstrate the implementation of user authentication and OTP verification in a Node.js application using Express.js and MongoDB.
- User authentication using OTP
- User signup
- User login
- Sending OTP for verification
- Node.js
- Express.js
- MongoDB
- Mongoose
- JSON Web Tokens (JWT)
-
Clone the repository:
git clone https://github.com/yourusername/otp_project.git
- go into the project folder.
cd otp_project npm install
- Rename the example.env file to .env and provide the necessary environment variables:
PORT=3000 MONGODB_URI=mongodb://localhost:27017/otp_project JWT_SECRET=your_jwt_secret
-
Start the server
npm run dev
-
Use a tool like Postman to send requests to the API endpoints.
- Sendotp
in body send
http://localhost:4000/api/v1/sendotp
{ "number": "1231231232" }
- Signup
in body send the otp from the header
http://localhost:4000/api/v1/signup
{ "number": "1231231232", "otp": "181845" }
- login
in body send the updated otp generated
http://localhost:4000/api/v1/login
{ "number": "1231231232", "otp": "181845" }
- Sendotp
This project is licensed under the MIT License.