Skip to content

一个 Nodejs + Redis 的邮箱验证码+验证服务,易移植,易使用。

License

Notifications You must be signed in to change notification settings

CrazyMrYan/easy-verify

Repository files navigation

EasyVerify

GitHub License GitHub Tag GitHub last commit GitHub package.json version GitHub Issues or Pull Requests

EasyVerify 是一个基于 Node.js 和 Redis 的开源邮件验证码服务,提供发送和校验验证码的功能。

preview

功能

  • 生成并发送验证码到指定邮箱
  • 验证用户输入的验证码是否正确
  • 可配置的验证码有效期

配置

在根目录创建一个 .env.local 环境变量,配置以下内容

EMAIL_SERVICE=
EMAIL_USERNAME=
EMAIL_PASSWORD=
EMAIL_SEND_NAME=
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
PORT=3000
CODE_EXPIRE_TIME=120

使用

cd verify-code
yarn install

启动

yarn dev

API 文档

1. 发送验证码

请求

方法:POST

路径:/send-code

参数:

  • email (string): 接收验证码的邮箱地址
  • username (string): 用户名称(非必填)

示例

curl -X POST http:https://localhost:3000/send-code -d "[email protected]"

2. 校验验证码

请求

方法:POST

路径:/verify-code

参数: email (string): 接收验证码的邮箱地址 code (string): 用户输入的验证码

示例

curl -X POST http:https://localhost:3000/verify-code -d "[email protected]&code=123456"

贡献

欢迎贡献代码!请提交 Pull Request 或报告问题到 issues。

许可证

本项目使用 MIT 许可证。请参阅 LICENSE 文件了解更多信息。