yuheng/src/plugins/encryption/index.js
expressgy fdc4d67092 feat: 添加Redis支持、雪花ID生成器及集群模式
- 新增Redis插件,支持分布式锁及缓存功能
- 引入雪花ID生成器,用于生成唯一用户ID
- 实现集群模式,支持多线程运行
- 优化用户注册逻辑,增加分布式锁机制
- 更新配置文件,添加Redis及雪花ID相关配置
- 修复部分代码格式及数据库字段类型
2025-03-26 00:42:33 +08:00

13 lines
434 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);