sendcode
v1.0.0
Published
Send the generated code to the given phone number with any SMS sending service
Downloads
6
Maintainers
Readme
Send verification code via sms
Send the generated code to the given phone number with any SMS sending service.
✨ This is the main task of this module. ✨
The code generated by faker module is 5 digits. Of course, you can change the number of these figures.
Features & Ability
- Ability to change the number of digits of the sent code
- Ability to test and document api with swagger
- Ability to change SMS sending service
- Ability to save given phone number and it's code in redis database
Features of generated code
- If the code has been generated once, no more code will be generated.
- The code will expire after 60 seconds.
- If the user uses the code once, he cannot use it again.
Tech
This module uses a number of open source projects to work properly:
- Node.js - evented I/O for the backend
- Swagger - Simplifying API development
- Redis - open source, in-memory data structure store, used as a database, cache, and message broker
- Fastify - Fast and low overhead web framework, for Node.js
- Faker - Generate massive amounts of fake (but realistic) data for testing and development.
✨ This project was bootstrapped with Fastify-CLI. ✨
Installation guide for the user
git clone https://github.com/tendal-lox/Send-verification-code-via-sms.git
cd sendCode
Note: You need to install fastify-cli for this module to work properly.
Installation guide for developers
npm install Send-verification-code-via-sms
npm run dev
To start the app in dev mode.
Open http://localhost:3000/docs/static/index.html to view it in the browser.
Note: SMS sending service is according to the country of Iran. So you have to adjust it according to your country. For this, you need to enter /routes/sendVerificationCode.js and change this part of the code:
// Kavenegar send api
const api = Kavenegar.KavenegarApi({apikey: 'api key from kavenegar'});
api.Send({ message: generateCode , sender: "xxx" , receptor: phoneNumber })
Bugs are being fixed
There is no any problem in the production code, but there is a problem in the test. Since there is no database in the test file, when you run npm test you will always encounter a database connection problem.
License
MIT