- 新增Redis插件,支持分布式锁及缓存功能 - 引入雪花ID生成器,用于生成唯一用户ID - 实现集群模式,支持多线程运行 - 优化用户注册逻辑,增加分布式锁机制 - 更新配置文件,添加Redis及雪花ID相关配置 - 修复部分代码格式及数据库字段类型
13 lines
434 B
JavaScript
13 lines
434 B
JavaScript
import { hash } from 'bcrypt';
|
||
import fastifyPlugin from 'fastify-plugin';
|
||
// 加密
|
||
async function encryption(fastify, options) {
|
||
// 注册swagger插件(新版配置方式)
|
||
fastify.log.warn('Register Encryption Plugin!');
|
||
// 初始化时注册插件
|
||
fastify.decorate('hash', (str, salt = 10) => hash(str, salt));
|
||
fastify.log.warn('Register Encryption complete!');
|
||
}
|
||
|
||
export default fastifyPlugin(encryption);
|