330 Commits

Author SHA1 Message Date
6d4e600be5 修复一个文件大小写错误.. 2025-06-23 01:39:14 +08:00
610a0fc657 .. 2025-06-23 01:38:49 +08:00
be75bb7bc1 lint 2025-06-23 01:30:02 +08:00
3ef9285278 完成链接复制 2025-06-23 01:29:02 +08:00
3e156d3f5d 不要乱给Image加fill 2025-06-23 01:13:28 +08:00
f82fc0fb77 修复了几个damn的bug,终于可以用户端访问了 2025-06-23 01:12:25 +08:00
d40392745a 完成剩余需求 2025-06-23 00:43:27 +08:00
edc605fb62 完成博客权限修改 2025-06-23 00:07:23 +08:00
a38463837f 优化组件提取实现 2025-06-22 23:34:20 +08:00
38fa0a0a07 提取blogPermissionCheckBoxs组件 2025-06-22 23:31:55 +08:00
d4679f3733 完成博客添加时的权限指定 2025-06-22 23:26:12 +08:00
5ae62d5d22 调整数据库结构、添加博客权限enum 2025-06-22 23:25:38 +08:00
063181da5a lint 2025-06-22 21:17:39 +08:00
0eed6cfdbf 提交1.0.0的README 2025-06-22 21:06:56 +08:00
e6087f43d0 修复oss中effect重复循环执行的问题 2025-06-22 20:43:38 +08:00
da98961b8b 调整web到3002端口 2025-06-20 00:48:15 +08:00
6d3efa57ca 修复博客ip错误 2025-06-20 00:42:03 +08:00
d1d1870100 lint 2025-06-19 23:53:28 +08:00
0758b9f75a 重构ossStore 2025-06-19 23:07:06 +08:00
6e73220962 lint 2025-06-19 22:03:57 +08:00
8f2df85208 重构OssStore 2025-06-19 22:03:50 +08:00
1bd717f84f 标准化博客评论命名 2025-06-19 16:06:09 +08:00
bb9fa3bcaa 优化博客与博客评论关系 2025-06-19 16:03:27 +08:00
bf3b2f7a94 博客评论限流5/min,添加前端错误处理 2025-06-19 15:42:38 +08:00
325c2e3a87 userMe处理无token情况,节省资源 2025-06-19 15:24:44 +08:00
c262778373 添加userMe错误重试判定 2025-06-19 15:20:02 +08:00
c782145e7e 实现博客评论用户提示 2025-06-19 15:16:55 +08:00
cb2258aa64 提升userMe到hook中 2025-06-19 15:01:08 +08:00
da16bc1dbe 添加控制台菜单加载态 2025-06-19 14:55:58 +08:00
43e814fbe7 为hook的useSWR添加错误消息 2025-06-19 11:51:23 +08:00
4c9505d476 添加邮件限流 2025-06-19 11:41:30 +08:00
b79c84a004 发送验证码、登陆接口限流20/min 2025-06-19 11:27:00 +08:00
70b90c3ed7 前端禁用发送短信验证码 2025-06-19 11:23:16 +08:00
83b15ddf37 实现邮件验证发送 2025-06-19 11:21:34 +08:00
0f4d6be36f 暂时移除手机登陆方式 2025-06-19 09:36:08 +08:00
a1a16afb76 创建账户信息组件 2025-06-19 09:30:04 +08:00
70c89b783a 移动USER_ME_CACHE_KEY到UserApi中、登出移除该缓存 2025-06-19 09:15:03 +08:00
bd862e54fa 实现权限级菜单、localStorageSWR缓存 2025-06-19 09:03:52 +08:00
af0e9c6522 前端user/me提升到console/layout 2025-06-18 17:26:50 +08:00
acaf14c403 后端实现权限验证 2025-06-18 17:10:55 +08:00
f62e2ad2a6 彻底移除权限模块。。。 2025-06-18 16:23:08 +08:00
ec090e3e20 彻底移除权限模块 2025-06-18 16:16:46 +08:00
4e306adc9f 后端移除所有权限模块 2025-06-18 15:54:13 +08:00
38fa850e38 修改网站描述 2025-06-18 15:46:30 +08:00
041e27c87d 修复批量删除object参数错误 2025-06-17 17:01:53 +08:00
6d09087289 上传文件成功自动从列表删除 2025-06-17 16:58:53 +08:00
7e05789fe5 封装ossStore 2025-06-17 16:53:53 +08:00
e418476b20 添加登陆接口限流 2025-06-17 09:37:24 +08:00
90a67b681e format + lint 2025-06-14 14:12:18 +08:00
e777afc433 添加邮件系统page 2025-06-10 21:37:36 +08:00
749cb2e13b 调整控制台侧边栏用户管理 2025-06-10 21:21:57 +08:00
7b7f940a60 调整博客、资源表格,允许任意位置换行 2025-06-10 15:37:56 +08:00
0461c0ce70 下载存储文件在新窗口打开 2025-06-10 15:03:28 +08:00
613f9e1a8c 优化存储界面文件数量提示 2025-06-10 14:59:57 +08:00
2c75d6de4a 优化存储界面 2025-06-10 14:57:52 +08:00
65db82ce60 修复修改密码导致界面无法点击的问题 2025-06-10 14:53:54 +08:00
19dc49b10d 完成ali-oss文件管理 2025-06-10 13:52:35 +08:00
3211e25bd6 ossSts添加缓存 2025-06-08 22:36:14 +08:00
359ab3b072 后端实现OssSts 2025-06-08 22:24:59 +08:00
b16e454058 完成博客评论添加ip的控制器 2025-06-08 22:10:47 +08:00
2698d5f133 博客评论添加ip及地址 2025-06-08 22:00:02 +08:00
e0b80ea422 博客图片优化鼠标hover样式 2025-06-08 21:50:55 +08:00
448bed89bd 控制台允许返回首页 2025-06-08 12:00:48 +08:00
accd5b8754 实现博客评论 2025-06-07 15:19:43 +08:00
73e409ce84 实现评论本地更新 2025-06-07 13:49:33 +08:00
3821ef6657 初步完成评论 2025-06-07 03:21:27 +08:00
c872b55083 添加邮件模块 2025-05-20 14:11:22 +08:00
c2914d8e29 移除所有的.DS_Store 2025-05-20 13:48:16 +08:00
0ebda96d62 实现修改密码,但引入了修改密码后无法点击窗口的bug 2025-05-18 23:18:42 +08:00
1baff0712a 实现用户注销和删除系统 2025-05-18 22:25:05 +08:00
4d9245aabb user List方法包含软删除的用户 2025-05-18 21:47:02 +08:00
263ad2a0ae 删除adminUserService,合并到userService中 2025-05-18 21:44:33 +08:00
4bace58823 对软删除的用户登录进行处理 2025-05-18 21:39:39 +08:00
d5d799b425 user服务findOne方法添加withDeleted选项 2025-05-18 21:39:13 +08:00
b0a8ac9d66 优化修改用户密码时失败处理 2025-05-18 21:29:17 +08:00
ef7dae1bae 优化用户登录账号删除的情况 2025-05-18 21:28:55 +08:00
e25c4f0455 优化Blog管理列表样式 2025-05-18 21:02:53 +08:00
f1f32f03ec 博客文章添加a标签样式 2025-05-18 20:53:42 +08:00
cbd4ca5686 添加博客成功自动重置表单 2025-05-18 16:04:30 +08:00
8992963da8 修复blank拼写错误 2025-05-18 16:02:08 +08:00
6f172c6cb6 实现访问博客计数 2025-05-18 16:01:12 +08:00
02a73a5e33 优化加载台和错误 2025-05-18 15:56:54 +08:00
44a1da5be2 实现iframe等元素的渲染 2025-05-18 15:47:27 +08:00
b4ade3bdd1 优化图片预览 2025-05-18 15:38:09 +08:00
5d9dfe7382 实现博客内容解析 2025-05-18 15:25:25 +08:00
393377b5da 修复footer联系我文本换行问题 2025-05-18 15:25:13 +08:00
42e9bd0f0b 整理依赖 2025-05-18 14:32:15 +08:00
7730ae7981 初步完成渲染博客文章 2025-05-18 14:30:53 +08:00
3f0e281d42 实现blog后端api 2025-05-18 14:30:18 +08:00
327f49bff0 实现blog列表 2025-05-18 14:30:03 +08:00
e1606b707e 添加base62编码工具 2025-05-18 14:29:50 +08:00
39f3e6b93c 完成BlogApi 2025-05-18 14:29:42 +08:00
4f5f771e2b 完成博客增删改查 2025-05-16 22:10:21 +08:00
e782b926a4 实现添加博客 2025-05-16 21:58:33 +08:00
dc0a8a1071 添加资源界面添加描述 2025-05-16 21:29:29 +08:00
7ab982e4fd 添加资源界面加载态和错误 2025-05-16 17:33:01 +08:00
7a612f8480 实现登出 2025-05-13 11:58:29 +08:00
c6cc3a7098 修复一个apiError的错误 2025-05-13 11:58:16 +08:00
088e168460 优化header 2025-05-13 11:35:17 +08:00
b6d9a518e8 优化控制台user 2025-05-13 11:35:03 +08:00
96e8d0e090 添加图片oss域 2025-05-13 11:34:37 +08:00
5e7ed3d6f7 完成me接口 2025-05-13 10:53:25 +08:00
134335021d 修复header导致服务端客户端渲染不一致问题 2025-05-12 22:51:43 +08:00
b764d3c932 调整组件位置 2025-05-12 22:43:24 +08:00
367ec1d9a0 调整用户图标 2025-05-12 22:41:21 +08:00
af3b4b0cc3 移除未使用的引用 2025-05-12 22:41:11 +08:00
fcec99f1c5 优化资源图片质量、添加tagId 2025-05-12 22:40:58 +08:00
7d065d1264 资源标题样式调整 2025-05-12 22:29:43 +08:00
51ed3a7747 样式小调整 2025-05-12 22:27:27 +08:00
92a3510547 优化文字溢出样式 2025-05-12 22:24:23 +08:00
ee4feb57c5 优化编辑资源标签样式 2025-05-12 22:16:34 +08:00
5159fa3606 实现资源删除管理 2025-05-12 22:13:09 +08:00
53665f8847 实现resource界面 2025-05-12 21:50:53 +08:00
30224774e6 添加编辑资源加载态 2025-05-12 21:34:59 +08:00
e3ca7ac027 完成资源CRUD 2025-05-12 21:31:24 +08:00
bb054f7f5a 完成资源的增加和查询 2025-05-12 20:53:10 +08:00
2a1e0d45dd 修复前端api漏掉/api路径问题 2025-05-12 16:01:37 +08:00
8e0d7dc873 为resourceListAPi添加类型声明 2025-05-12 16:00:23 +08:00
259fae4c63 修复文件夹命名错误,添加命名空间 2025-05-12 15:54:06 +08:00
9133b45744 完成博客、资源管理api 2025-05-12 15:50:50 +08:00
eb4301ba98 实现后端webResource CRUD 2025-05-12 15:30:42 +08:00
7f441f5126 修复创建用户 密码name错误 2025-05-12 14:00:54 +08:00
054d505117 调整用户名长度4~32,昵称1~30 2025-05-12 13:56:20 +08:00
26142f9a71 新增自动刷新 2025-05-12 13:52:38 +08:00
11d503ab49 调整路径 2025-05-12 13:34:00 +08:00
748ea70c0d 优化错误处理表达 2025-05-12 13:30:48 +08:00
f1876e19bf 修复错误捕获 2025-05-12 13:30:09 +08:00
17bcb8787a 优化后端,实现前端添加用户 2025-05-12 13:29:29 +08:00
c17108e094 完成修改密码删除用户 2025-05-12 12:47:27 +08:00
5c29938730 修复前端直接修改user的问题 2025-05-12 12:18:14 +08:00
f16cbe5443 调整user实体,去掉id 2025-05-12 12:09:42 +08:00
f49a1503f0 完成了一些接口 2025-05-12 12:07:01 +08:00
4f782e4cea 完成admin-user-update 2025-05-12 11:40:21 +08:00
2dd088fdf3 完成admin-user-get 2025-05-12 10:45:56 +08:00
e5c0c354e5 完成管理员user-list 2025-05-12 10:27:50 +08:00
21cee7c3f1 引入俩新组件 2025-05-12 10:27:37 +08:00
369fe28c5c 后端验证服务成功返回true 2025-05-12 10:22:18 +08:00
17c065ae79 完成项目结构搭建 2025-05-10 19:13:50 +08:00
7bbcf2fac7 移除重复的控制台 2025-05-10 12:18:32 +08:00
d281a6c804 调整前端目录结构 2025-05-10 12:08:04 +08:00
2f86362f4b 完成用户权限管理 2025-05-08 23:13:24 +08:00
448a7b48ba 实现角色权限管理 2025-05-08 22:59:03 +08:00
a2972de417 实现admin-permission 2025-05-08 22:42:26 +08:00
98745895eb 实现admin-role 2025-05-08 22:38:50 +08:00
87d6c738c7 实现用户角色服务 2025-05-08 22:28:25 +08:00
2f9b922485 实现权限管理的服务 2025-05-08 22:26:04 +08:00
d2287bc363 实现管理段用户增删改查改密码 2025-05-08 22:07:06 +08:00
8e33f1b61b 验证pipe禁止未定义的字段 2025-05-08 22:06:44 +08:00
c2e5ab51df 完成管理员获取用户列表 2025-05-07 23:48:40 +08:00
b6f1495981 完成权限角色守卫 2025-05-07 23:14:57 +08:00
4df7de91d0 加入权限模块、用户模块加入userRole实体 2025-05-07 22:12:18 +08:00
c5463e9ffe 移除user实体不需要的引用 2025-05-07 22:04:34 +08:00
96a76568cc 添加验证码日志 2025-05-07 18:57:12 +08:00
9206b7fcc0 移除错误引入的服务 2025-05-07 18:33:41 +08:00
464931cc98 添加博客模块 2025-05-07 18:33:13 +08:00
9e09a7bc72 优化资源删除处理 2025-05-07 18:21:50 +08:00
3b2f4f1f40 优化资源查询 2025-05-07 18:17:37 +08:00
a661827842 添加资源模块,添加资源获取接口 2025-05-07 18:14:31 +08:00
9570fb4524 放弃短信验证了 2025-05-07 17:21:49 +08:00
8039a3571d 实现登录验证 2025-05-07 16:06:46 +08:00
c6471cc169 完成验证码发送和验证 2025-05-07 16:01:37 +08:00
8645380fbf 优化loginDto错误信息 2025-05-07 15:16:06 +08:00
37988b4582 优化表单验证错误处理 2025-05-07 15:14:09 +08:00
f5f80385ad 调整logout从get为post 2025-05-07 15:04:36 +08:00
97352e26b2 添加相应成功标准响应 2025-05-07 15:02:56 +08:00
6a44e902fd 实现登出接口 2025-05-07 14:44:07 +08:00
1246613fb1 完成jwt鉴权 2025-05-07 14:34:49 +08:00
d2744689b2 加入userSession Service 2025-05-07 13:38:14 +08:00
b75c4fb551 调整user实体🚰 2025-05-07 13:38:01 +08:00
166201371c user模块注册userSession实体 2025-05-07 13:37:27 +08:00
d03ce79653 实现auth模块的登录 2025-05-07 13:37:05 +08:00
9f60ea9228 auth模块加入userSession和jwt 2025-05-07 13:36:51 +08:00
fda2eb01ec app加入PassportModule 2025-05-07 13:36:36 +08:00
dda4f8da05 加入userSession实体 2025-05-07 13:36:26 +08:00
4d21045303 调整user实体位置 2025-05-07 13:36:06 +08:00
5316d922ab 加入了一些依赖 2025-05-07 13:35:58 +08:00
5dd0d7c2f3 auth模块导入user模块 2025-05-07 00:02:04 +08:00
d4c40db011 user模块导出Service 2025-05-07 00:01:49 +08:00
7985b141c0 允许userService进行or查询 2025-05-07 00:01:32 +08:00
1d434f03dd 更新user实体的密码哈希命名 2025-05-07 00:01:13 +08:00
062719adce 完善auth服务注释 2025-05-06 22:58:47 +08:00
e954f2fe76 优化登录controller对登录方式的处理 2025-05-06 22:54:38 +08:00
eef23909f4 完成后端登录dto验证 2025-05-06 22:52:51 +08:00
c2868b5128 完善前端blog types声明 2025-05-06 19:13:20 +08:00
36246d3263 更新登录注册逻辑 2025-05-06 09:25:57 +08:00
ebf48b6062 移除无用依赖 2025-04-26 22:00:13 +08:00
641f08a042 调整资源组件 2025-04-26 21:59:05 +08:00
e67a7f2f01 引入swr用于请求 2025-04-26 21:58:51 +08:00
c548add86e 优化资源样式 2025-04-26 21:11:17 +08:00
aa33643982 lint 2025-04-26 20:42:05 +08:00
77edc576ea 优化资源样式 2025-04-26 16:18:05 +08:00
6a1ef7b409 现在才是完成博客,刚刚是资源 2025-04-26 16:13:29 +08:00
1be4fea2f5 完成博客 2025-04-26 15:05:47 +08:00
c9fab9fa8f 优化登录页登录方式样式 2025-04-26 13:03:01 +08:00
016ba13466 完善console界面登录样式 2025-04-26 13:00:17 +08:00
d46b5a36b1 提交登录页背景图 2025-04-26 12:59:55 +08:00
5975b71dcc 完善登录page 2025-04-26 12:59:45 +08:00
78fe191845 完善matedata 2025-04-26 12:59:36 +08:00
2c53203473 完成登录界面样式 2025-04-25 23:23:46 +08:00
bcecdcf9ef 优化首页 2025-04-25 22:25:42 +08:00
5c956ba949 引入头像,完成首页 2025-04-25 22:24:37 +08:00
c161a6d298 优化footer 2025-04-25 21:43:42 +08:00
842d834c6d 实现header、调整路由 2025-04-25 21:42:02 +08:00
1416043529 引入对话框和vaul图标库 2025-04-25 21:41:01 +08:00
3a10e6abb7 优化footer 2025-04-24 22:47:12 +08:00
8fbbcabc57 添加默认背景颜色 2025-04-24 22:45:19 +08:00
1a57c5ca49 优化header 2025-04-24 22:43:21 +08:00
870b04bb28 添加基础结构 2025-04-24 22:40:18 +08:00
777d36617f 加入依赖 2025-04-24 22:40:05 +08:00
440732bfb9 初步完成header和footor 2025-04-24 22:39:53 +08:00
2e3aed0038 使用shadcn重构 2025-04-24 19:37:31 +08:00
72f6893660 提交nextjs新项目 2025-04-24 17:46:11 +08:00
b0728746cd 更新gitignore文件 2025-04-24 17:44:22 +08:00
6a46d6dce7 logo也先不要了 2025-04-18 22:00:41 +08:00
25ec96492f 重构项目 2025-04-17 16:11:44 +08:00
28a113c132 优化Blog样式 2025-03-04 23:20:53 +08:00
ebf6530c1f 修复user表作用域问题 2025-02-16 23:51:56 +08:00
bb83a87748 移除无用的时间函数 2025-02-16 23:40:29 +08:00
52cbe2a7ed 修改后端启动方式 2025-02-16 23:28:51 +08:00
1d7e2dc5b4 修改后段博客内容时间字段 2025-02-16 23:23:49 +08:00
58f5a715f2 修复博客内容时间字段问题 2025-02-16 23:16:54 +08:00
5c0951fc64 移除无用的依赖 2025-02-16 23:09:00 +08:00
9af60b0dbe 使用pg数据库重构 2025-02-16 23:08:25 +08:00
3d729996bb 前端首页置标题 2025-01-17 12:42:44 +08:00
65927214ed 修复 前端Header菜单文本换行问题 2024-10-25 21:52:54 +08:00
35f11ccb83 优化 前端博客内容页面样式,调整最小宽度为700px 2024-10-16 22:49:19 +08:00
30f84486fa 优化 前端使用协议样式 2024-10-16 22:44:25 +08:00
19ba954c6b 优化 前端博客列表中描述样式 2024-10-16 22:29:16 +08:00
2589b24673 修复 后端获取博客内容后 访问次数不+1的情况 2024-10-16 22:21:08 +08:00
e3eef8e23f 优化 前端博客内容空提示 2024-10-16 22:17:22 +08:00
2bc3e5221d 添加 前端博客列表加密文章提示 2024-10-16 22:10:01 +08:00
96ff60e3ec 添加 服务端查询博客列表时返回access_level字段 2024-10-16 21:54:03 +08:00
923f499709 添加 自动刷新Token功能以维持登录状态 2024-10-16 21:49:04 +08:00
87977298e9 添加 服务端API中RequestData数据类型定义 2024-10-16 21:48:14 +08:00
539050629d 修复 前端BlogContent a标签深色模式的样式 2024-10-16 01:50:21 +08:00
ed64e2b846 添加 前端BlogContent对表格的样式支持 2024-10-16 01:41:27 +08:00
8061f3d292 添加 加密博客文章功能 2024-10-16 01:35:41 +08:00
702869e1f8 优化 前端控制台界面样式 2024-10-15 23:43:05 +08:00
46396153e3 优化 前端Dashboard样式实现 2024-10-14 10:37:53 +08:00
b707b27020 优化 前端深色模式样式 2024-10-13 14:31:24 +08:00
5c7bd5bb74 修复 elementplus深色模式不能实时变化的问题 2024-10-13 14:18:36 +08:00
0ebcb79259 优化 前端BlogContent 2024-10-12 12:27:25 +08:00
f990d81ca2 优化 前端深色模式样式 2024-10-12 11:43:46 +08:00
07b95549fd 添加 ElementPlus深色模式 2024-10-12 11:02:49 +08:00
53e63f4d6a 优化 前端Login登录按钮样式实现 2024-10-12 11:00:57 +08:00
65a2ad75dd 修复 前端NotFound组件销毁标题不重置的问题 2024-10-12 11:00:18 +08:00
607f0a7a4d 优化 前端NotFound界面 2024-10-12 10:54:32 +08:00
8399c9e8a7 优化 文件上传后提示逻辑 2024-10-08 15:27:00 +08:00
07ee1f906f 添加 文件上传失败原因提示 2024-10-08 12:57:52 +08:00
4c3731da70 添加 深色模式 2024-10-08 02:43:17 +08:00
e856af135c 优化 Ace编辑器对语言的支持 2024-10-06 00:38:19 +08:00
ed5be9ec39 添加 OSS文件在线编辑功能package依赖 2024-10-06 00:04:43 +08:00
19ef964c08 添加 OSS文件在线编辑功能 2024-10-06 00:04:21 +08:00
f2bb14bb17 优化 OSS文件上传 文件切片、下载文件逻辑、文件操作界面逻辑 2024-10-05 22:37:04 +08:00
840b427a7e 添加 前端 OSS文件管理 2024-10-05 01:32:06 +08:00
9adcc812a3 添加 服务端GetOSSToken接口 2024-10-05 01:30:59 +08:00
57e8d9ac21 优化 Resources管理界面 2024-10-01 16:39:32 +08:00
35fcf700e2 移除 tonecn中的pnpm-lock 2024-09-30 12:52:44 +08:00
09df4d6475 gitignore加入pnpm-lock 2024-09-30 12:50:49 +08:00
c477af2fad 优化 Resource Download中标签样式 2024-09-30 00:19:43 +08:00
3d56faa361 重构 Footer tailwind 2024-09-30 00:17:18 +08:00
fc28b9cf04 重构 Rotation tailwind 2024-09-29 23:22:04 +08:00
d86a9bfe94 重构 Login tailwind 2024-09-29 23:05:34 +08:00
d754ad1eba 重构 BlogContent tailwind 2024-09-29 22:51:17 +08:00
57997bf184 重构 Blog tailwindcss 2024-09-29 22:18:17 +08:00
f6720db786 修复 Header 菜单下边框选中样式层叠失败的问题 2024-09-29 20:40:20 +08:00
83335d01ef 重构 Download tailwind 2024-09-29 19:36:49 +08:00
670f4f9ea5 重构 Resource tailwind 2024-09-29 19:36:41 +08:00
ae15665b2f 重构 HomeView tailwind 2024-09-29 01:18:17 +08:00
e8bea369b8 重构 Header.vue-tailwind 2024-09-29 00:55:06 +08:00
f9a7c0c5c4 添加 tailwindcss 2024-09-28 22:27:23 +08:00
8d301bdbd1 优化 Logger日志颜色显示 2024-09-13 17:36:51 +08:00
986fde4724 优化 login控制台响应式布局 2024-09-12 22:00:55 +08:00
d01efd710e 优化 notfound界面响应式布局 2024-09-12 21:27:37 +08:00
36d33d9f11 优化 blogContent加载完成前工具栏出现的问题 2024-09-12 20:32:31 +08:00
7b5dacf723 添加404界面,优化homeview代码可读性 2024-09-12 20:29:45 +08:00
d41e43fcb8 优化config.ts 2024-09-12 20:14:09 +08:00
f183e7566e 登录时按下回车键触发登录 2024-09-06 16:10:51 +08:00
2eab11561d 修复typescript类型错误 2024-09-06 16:10:46 +08:00
5b7c5d0f1d 前端加入request中间件,jwtToken失效自动清除localstorage及刷新界面 2024-09-06 15:38:55 +08:00
9815f0efdf 优化captchaSession 2024-09-06 12:00:07 +08:00
bfa5042f07 修改APILoader以保持API统一 2024-09-06 11:59:04 +08:00
52a1cd2817 为API抽象类添加注解和类型限定 2024-09-06 11:58:24 +08:00
b232d6648c 优化MySQL连接池 2024-09-06 11:57:45 +08:00
672b4b771e 删除无用配置文件 2024-09-06 11:57:15 +08:00
dbdf9e415e 前端添加网站图标及优化标签页标题 2024-09-01 16:42:22 +08:00
8ac701f214 更改IPlocationAPI查询接口 2024-09-01 16:41:35 +08:00
fdac3b1433 修改服务端部署配置 2024-09-01 16:41:18 +08:00
7e30cef008 自动导入element-plug 2024-09-01 15:49:10 +08:00
1709552ed4 修复路由守卫next多次调用的问题 2024-09-01 15:47:33 +08:00
0d33e18a88 博客评论后重加载评论 2024-09-01 15:47:10 +08:00
d3106a6576 后端添加tonesc.cn跨域 2024-09-01 15:46:51 +08:00
ac86ab23ad 前端添加实用工具 2024-09-01 15:28:34 +08:00
acbf404780 前端完成Blogs管理界面 2024-09-01 14:37:47 +08:00
d533bd528d 后端完成博客管理接口 2024-09-01 14:37:21 +08:00
55b631cd9c 后端实现Resources修改接口 2024-09-01 13:46:10 +08:00
241834feb8 Dashboard完成、Resources编辑完成 2024-09-01 13:45:41 +08:00
96e8afca57 request自动添加jwtToken 2024-09-01 13:44:59 +08:00
8755df31c9 cors允许DELETE方法 2024-09-01 13:44:46 +08:00
f48395dda1 优化博客评论显示 2024-08-31 23:43:57 +08:00
c397f7b1e5 优化Blog容器高度 2024-08-31 22:57:45 +08:00
8ecf54d8af 修复因棒棒糖导致的Header高度不统一情况 2024-08-31 22:56:07 +08:00
97b02556ba 修复Header中控制台RouterLink指向 2024-08-31 22:53:33 +08:00
49415eb4db 前端登录功能补充 2024-08-31 22:53:02 +08:00
a008ff96ed 前端完成登录功能 2024-08-31 22:52:44 +08:00
1cd705665e 后端完成jwt登录接口 2024-08-31 22:52:31 +08:00
9b0cdf18f5 修复博客内容样式 2024-08-31 16:24:36 +08:00
7d6e056e6b 优化博客访问量显示 2024-08-31 15:05:16 +08:00
30e8e89422 将博客评论组件加入到博客内容中 2024-08-31 14:57:30 +08:00
a154b3fa39 完成前端博客评论展示组件 2024-08-31 14:57:10 +08:00
c6ab1ea75d 新增获取博客评论接口 2024-08-31 14:50:53 +08:00
c2956adb4b 修复提交博客评论未进行人机验证检验的bug 2024-08-31 14:50:13 +08:00
8ea3a7b25c 完善博客评论功能 2024-08-31 13:38:22 +08:00
29f2c09a69 后端加入Redis、旋转图片验证接口 2024-08-30 21:34:24 +08:00
a69cd3af61 前端加入旋转图像验证组件 2024-08-30 21:33:43 +08:00
458b38b2d9 优化MysqlConnection日志 2024-08-30 21:33:16 +08:00
3b82fbbd1a 加入BlogContent工具栏,完成点赞功能 2024-08-30 16:28:25 +08:00
a5d1842895 添加访问博客次数显示 2024-08-30 16:07:00 +08:00
3f01207c29 BlogList接口返回访问量及点赞量 2024-08-30 12:54:22 +08:00
1da28cd78d 添加pnpm-lock 到gitignore 2024-08-30 12:47:30 +08:00
2a9cc506f0 完成前端BlogContent界面 2024-08-30 12:46:58 +08:00
223fbf39b2 完善BlogContent接口,完善ServerDtdResponse 2024-08-30 12:46:35 +08:00
8a6ee6d98c 后端移除AuthAdmin中间件 2024-08-30 12:46:07 +08:00
39b93997c2 修复Header组件中博客文章和列表显示的问题 2024-08-30 12:45:37 +08:00
3a6e364c70 完成前端Blog界面 2024-08-30 01:09:05 +08:00
87166564fc 加入时间戳转字符串库 2024-08-30 01:08:44 +08:00
2078b0a934 修改主页描述 2024-08-29 22:21:43 +08:00
f7ee30f5dd 完善资源/下载页面 2024-08-29 22:21:32 +08:00
4d45b22592 修复request封装返回数据结构 2024-08-29 22:02:57 +08:00
bc99fba385 重构后端,完善获取资源/下载列表、博客列表接口 2024-08-29 21:59:55 +08:00
274 changed files with 26173 additions and 4849 deletions

30
.gitignore vendored
View File

@@ -1,31 +1 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.tsbuildinfo
pnpm-lock.yaml

View File

@@ -0,0 +1,48 @@
# TONE_Page 个人博客
## 简介
一款由NextJS+NustJS(+Postgres)打造的现代化个人博客平台
## 功能特性
- 资源/工具发布
- 博客发布
- 博客评论及回复
- 用户系统(支持账号密码登录、邮箱验证码登录)
## 安装与运行
```bash
git clone https://git.tonesc.cn/tone/tonePage.git
# 后端
cd tone-page-server
touch .env # 创建并编辑环境变量,需要包含以下信息
npm run build
npm run start:prod
# 前端
cd tone-page-web
npm run build
npm run start
```
```bash
# 后端环境变量
DATABASE_HOST= # 数据库地址Postgres
DATABASE_PORT= # 数据库端口
DATABASE_NAME= # 数据库名称
DATABASE_USERNAME= # 数据库用户名
DATABASE_PASSWORD= # 数据库密码
JWT_SECRET= # JWT密钥任意均可
JWT_EXPIRES_IN= # JWT过期时间例如1d、12h
ALIYUN_ACCESS_KEY_ID= # 阿里云RAM用户ACCESS_KEY_ID
ALIYUN_ACCESS_KEY_SECRET= # 阿里云RAM用户ACCESS_KEY_SECRET
ALIYUN_OSS_STS_ROLE_ARN= # 阿里云OSS_STS需要扮演的角色ARN
NODE_ENV=production # 保留该行表示在生产环境
```
## 注意事项
* 注意后端在正式进入生产环境前,需要先注释```NODE_ENV=production```以实现数据表结构初始化,完成后重启服务,并取消注释即可正式进入生产环境
* 若需使用pm2进行服务管理可通过```pm2 start "npm run start" --name "name"```启动
* 前端服务开放在3002端口后端服务开放在3001端口
## 许可证
MIT

View File

@@ -1,8 +0,0 @@
{
"mysql":{
"host":"server.tonesc.cn",
"user":"root",
"password":"245565",
"database":"tonecn"
}
}

View File

View File

@@ -1,8 +0,0 @@
{
"watch": ["*.ts"],
"execMap": {
"ts": "ts-node"
},
"ignore": ["*.test.ts"],
"ext": "ts"
}

View File

@@ -1,25 +0,0 @@
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^20.12.12",
"nodemon": "^3.1.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.19.2",
"ioredis": "^5.4.1",
"mysql2": "^3.9.7"
}
}

944
Server/pnpm-lock.yaml generated
View File

@@ -1,944 +0,0 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
cors:
specifier: ^2.8.5
version: 2.8.5
express:
specifier: ^4.19.2
version: 4.19.2
ioredis:
specifier: ^5.4.1
version: 5.4.1
mysql2:
specifier: ^3.9.7
version: 3.9.7
devDependencies:
'@types/node':
specifier: ^20.12.12
version: 20.12.12
nodemon:
specifier: ^3.1.0
version: 3.1.0
ts-node:
specifier: ^10.9.2
version: 10.9.2(@types/node@20.12.12)(typescript@5.4.5)
typescript:
specifier: ^5.4.5
version: 5.4.5
packages:
/@cspotcode/source-map-support@0.8.1:
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
engines: {node: '>=12'}
dependencies:
'@jridgewell/trace-mapping': 0.3.9
dev: true
/@ioredis/commands@1.2.0:
resolution: {integrity: sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==}
dev: false
/@jridgewell/resolve-uri@3.1.2:
resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
engines: {node: '>=6.0.0'}
dev: true
/@jridgewell/sourcemap-codec@1.4.15:
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
dev: true
/@jridgewell/trace-mapping@0.3.9:
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
dependencies:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.4.15
dev: true
/@tsconfig/node10@1.0.11:
resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==}
dev: true
/@tsconfig/node12@1.0.11:
resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==}
dev: true
/@tsconfig/node14@1.0.3:
resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==}
dev: true
/@tsconfig/node16@1.0.4:
resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==}
dev: true
/@types/node@20.12.12:
resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==}
dependencies:
undici-types: 5.26.5
dev: true
/accepts@1.3.8:
resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==}
engines: {node: '>= 0.6'}
dependencies:
mime-types: 2.1.35
negotiator: 0.6.3
dev: false
/acorn-walk@8.3.2:
resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==}
engines: {node: '>=0.4.0'}
dev: true
/acorn@8.11.3:
resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==}
engines: {node: '>=0.4.0'}
hasBin: true
dev: true
/anymatch@3.1.3:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
dependencies:
normalize-path: 3.0.0
picomatch: 2.3.1
dev: true
/arg@4.1.3:
resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
dev: true
/array-flatten@1.1.1:
resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==}
dev: false
/balanced-match@1.0.2:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
dev: true
/binary-extensions@2.3.0:
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
engines: {node: '>=8'}
dev: true
/body-parser@1.20.2:
resolution: {integrity: sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==}
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
dependencies:
bytes: 3.1.2
content-type: 1.0.5
debug: 2.6.9
depd: 2.0.0
destroy: 1.2.0
http-errors: 2.0.0
iconv-lite: 0.4.24
on-finished: 2.4.1
qs: 6.11.0
raw-body: 2.5.2
type-is: 1.6.18
unpipe: 1.0.0
transitivePeerDependencies:
- supports-color
dev: false
/brace-expansion@1.1.11:
resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
dependencies:
balanced-match: 1.0.2
concat-map: 0.0.1
dev: true
/braces@3.0.2:
resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==}
engines: {node: '>=8'}
dependencies:
fill-range: 7.0.1
dev: true
/bytes@3.1.2:
resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}
engines: {node: '>= 0.8'}
dev: false
/call-bind@1.0.7:
resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==}
engines: {node: '>= 0.4'}
dependencies:
es-define-property: 1.0.0
es-errors: 1.3.0
function-bind: 1.1.2
get-intrinsic: 1.2.4
set-function-length: 1.2.2
dev: false
/chokidar@3.6.0:
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
engines: {node: '>= 8.10.0'}
dependencies:
anymatch: 3.1.3
braces: 3.0.2
glob-parent: 5.1.2
is-binary-path: 2.1.0
is-glob: 4.0.3
normalize-path: 3.0.0
readdirp: 3.6.0
optionalDependencies:
fsevents: 2.3.3
dev: true
/cluster-key-slot@1.1.2:
resolution: {integrity: sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==}
engines: {node: '>=0.10.0'}
dev: false
/concat-map@0.0.1:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
dev: true
/content-disposition@0.5.4:
resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==}
engines: {node: '>= 0.6'}
dependencies:
safe-buffer: 5.2.1
dev: false
/content-type@1.0.5:
resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==}
engines: {node: '>= 0.6'}
dev: false
/cookie-signature@1.0.6:
resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==}
dev: false
/cookie@0.6.0:
resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==}
engines: {node: '>= 0.6'}
dev: false
/cors@2.8.5:
resolution: {integrity: sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==}
engines: {node: '>= 0.10'}
dependencies:
object-assign: 4.1.1
vary: 1.1.2
dev: false
/create-require@1.1.1:
resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
dev: true
/debug@2.6.9:
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
dependencies:
ms: 2.0.0
dev: false
/debug@4.3.4(supports-color@5.5.0):
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
dependencies:
ms: 2.1.2
supports-color: 5.5.0
/define-data-property@1.1.4:
resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==}
engines: {node: '>= 0.4'}
dependencies:
es-define-property: 1.0.0
es-errors: 1.3.0
gopd: 1.0.1
dev: false
/denque@2.1.0:
resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==}
engines: {node: '>=0.10'}
dev: false
/depd@2.0.0:
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
engines: {node: '>= 0.8'}
dev: false
/destroy@1.2.0:
resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==}
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
dev: false
/diff@4.0.2:
resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
engines: {node: '>=0.3.1'}
dev: true
/ee-first@1.1.1:
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
dev: false
/encodeurl@1.0.2:
resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==}
engines: {node: '>= 0.8'}
dev: false
/es-define-property@1.0.0:
resolution: {integrity: sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==}
engines: {node: '>= 0.4'}
dependencies:
get-intrinsic: 1.2.4
dev: false
/es-errors@1.3.0:
resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==}
engines: {node: '>= 0.4'}
dev: false
/escape-html@1.0.3:
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
dev: false
/etag@1.8.1:
resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
engines: {node: '>= 0.6'}
dev: false
/express@4.19.2:
resolution: {integrity: sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==}
engines: {node: '>= 0.10.0'}
dependencies:
accepts: 1.3.8
array-flatten: 1.1.1
body-parser: 1.20.2
content-disposition: 0.5.4
content-type: 1.0.5
cookie: 0.6.0
cookie-signature: 1.0.6
debug: 2.6.9
depd: 2.0.0
encodeurl: 1.0.2
escape-html: 1.0.3
etag: 1.8.1
finalhandler: 1.2.0
fresh: 0.5.2
http-errors: 2.0.0
merge-descriptors: 1.0.1
methods: 1.1.2
on-finished: 2.4.1
parseurl: 1.3.3
path-to-regexp: 0.1.7
proxy-addr: 2.0.7
qs: 6.11.0
range-parser: 1.2.1
safe-buffer: 5.2.1
send: 0.18.0
serve-static: 1.15.0
setprototypeof: 1.2.0
statuses: 2.0.1
type-is: 1.6.18
utils-merge: 1.0.1
vary: 1.1.2
transitivePeerDependencies:
- supports-color
dev: false
/fill-range@7.0.1:
resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==}
engines: {node: '>=8'}
dependencies:
to-regex-range: 5.0.1
dev: true
/finalhandler@1.2.0:
resolution: {integrity: sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==}
engines: {node: '>= 0.8'}
dependencies:
debug: 2.6.9
encodeurl: 1.0.2
escape-html: 1.0.3
on-finished: 2.4.1
parseurl: 1.3.3
statuses: 2.0.1
unpipe: 1.0.0
transitivePeerDependencies:
- supports-color
dev: false
/forwarded@0.2.0:
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
engines: {node: '>= 0.6'}
dev: false
/fresh@0.5.2:
resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==}
engines: {node: '>= 0.6'}
dev: false
/fsevents@2.3.3:
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
dev: true
optional: true
/function-bind@1.1.2:
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
dev: false
/generate-function@2.3.1:
resolution: {integrity: sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==}
dependencies:
is-property: 1.0.2
dev: false
/get-intrinsic@1.2.4:
resolution: {integrity: sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==}
engines: {node: '>= 0.4'}
dependencies:
es-errors: 1.3.0
function-bind: 1.1.2
has-proto: 1.0.3
has-symbols: 1.0.3
hasown: 2.0.2
dev: false
/glob-parent@5.1.2:
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
engines: {node: '>= 6'}
dependencies:
is-glob: 4.0.3
dev: true
/gopd@1.0.1:
resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==}
dependencies:
get-intrinsic: 1.2.4
dev: false
/has-flag@3.0.0:
resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==}
engines: {node: '>=4'}
/has-property-descriptors@1.0.2:
resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==}
dependencies:
es-define-property: 1.0.0
dev: false
/has-proto@1.0.3:
resolution: {integrity: sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==}
engines: {node: '>= 0.4'}
dev: false
/has-symbols@1.0.3:
resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==}
engines: {node: '>= 0.4'}
dev: false
/hasown@2.0.2:
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
engines: {node: '>= 0.4'}
dependencies:
function-bind: 1.1.2
dev: false
/http-errors@2.0.0:
resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==}
engines: {node: '>= 0.8'}
dependencies:
depd: 2.0.0
inherits: 2.0.4
setprototypeof: 1.2.0
statuses: 2.0.1
toidentifier: 1.0.1
dev: false
/iconv-lite@0.4.24:
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
engines: {node: '>=0.10.0'}
dependencies:
safer-buffer: 2.1.2
dev: false
/iconv-lite@0.6.3:
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
engines: {node: '>=0.10.0'}
dependencies:
safer-buffer: 2.1.2
dev: false
/ignore-by-default@1.0.1:
resolution: {integrity: sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==}
dev: true
/inherits@2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
dev: false
/ioredis@5.4.1:
resolution: {integrity: sha512-2YZsvl7jopIa1gaePkeMtd9rAcSjOOjPtpcLlOeusyO+XH2SK5ZcT+UCrElPP+WVIInh2TzeI4XW9ENaSLVVHA==}
engines: {node: '>=12.22.0'}
dependencies:
'@ioredis/commands': 1.2.0
cluster-key-slot: 1.1.2
debug: 4.3.4(supports-color@5.5.0)
denque: 2.1.0
lodash.defaults: 4.2.0
lodash.isarguments: 3.1.0
redis-errors: 1.2.0
redis-parser: 3.0.0
standard-as-callback: 2.1.0
transitivePeerDependencies:
- supports-color
dev: false
/ipaddr.js@1.9.1:
resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==}
engines: {node: '>= 0.10'}
dev: false
/is-binary-path@2.1.0:
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
engines: {node: '>=8'}
dependencies:
binary-extensions: 2.3.0
dev: true
/is-extglob@2.1.1:
resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==}
engines: {node: '>=0.10.0'}
dev: true
/is-glob@4.0.3:
resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==}
engines: {node: '>=0.10.0'}
dependencies:
is-extglob: 2.1.1
dev: true
/is-number@7.0.0:
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
engines: {node: '>=0.12.0'}
dev: true
/is-property@1.0.2:
resolution: {integrity: sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==}
dev: false
/lodash.defaults@4.2.0:
resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==}
dev: false
/lodash.isarguments@3.1.0:
resolution: {integrity: sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==}
dev: false
/long@5.2.3:
resolution: {integrity: sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==}
dev: false
/lru-cache@7.18.3:
resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==}
engines: {node: '>=12'}
dev: false
/lru-cache@8.0.5:
resolution: {integrity: sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==}
engines: {node: '>=16.14'}
dev: false
/make-error@1.3.6:
resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==}
dev: true
/media-typer@0.3.0:
resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==}
engines: {node: '>= 0.6'}
dev: false
/merge-descriptors@1.0.1:
resolution: {integrity: sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==}
dev: false
/methods@1.1.2:
resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==}
engines: {node: '>= 0.6'}
dev: false
/mime-db@1.52.0:
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
engines: {node: '>= 0.6'}
dev: false
/mime-types@2.1.35:
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
engines: {node: '>= 0.6'}
dependencies:
mime-db: 1.52.0
dev: false
/mime@1.6.0:
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
engines: {node: '>=4'}
hasBin: true
dev: false
/minimatch@3.1.2:
resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
dependencies:
brace-expansion: 1.1.11
dev: true
/ms@2.0.0:
resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==}
dev: false
/ms@2.1.2:
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
/ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
dev: false
/mysql2@3.9.7:
resolution: {integrity: sha512-KnJT8vYRcNAZv73uf9zpXqNbvBG7DJrs+1nACsjZP1HMJ1TgXEy8wnNilXAn/5i57JizXKtrUtwDB7HxT9DDpw==}
engines: {node: '>= 8.0'}
dependencies:
denque: 2.1.0
generate-function: 2.3.1
iconv-lite: 0.6.3
long: 5.2.3
lru-cache: 8.0.5
named-placeholders: 1.1.3
seq-queue: 0.0.5
sqlstring: 2.3.3
dev: false
/named-placeholders@1.1.3:
resolution: {integrity: sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w==}
engines: {node: '>=12.0.0'}
dependencies:
lru-cache: 7.18.3
dev: false
/negotiator@0.6.3:
resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==}
engines: {node: '>= 0.6'}
dev: false
/nodemon@3.1.0:
resolution: {integrity: sha512-xqlktYlDMCepBJd43ZQhjWwMw2obW/JRvkrLxq5RCNcuDDX1DbcPT+qT1IlIIdf+DhnWs90JpTMe+Y5KxOchvA==}
engines: {node: '>=10'}
hasBin: true
dependencies:
chokidar: 3.6.0
debug: 4.3.4(supports-color@5.5.0)
ignore-by-default: 1.0.1
minimatch: 3.1.2
pstree.remy: 1.1.8
semver: 7.6.2
simple-update-notifier: 2.0.0
supports-color: 5.5.0
touch: 3.1.1
undefsafe: 2.0.5
dev: true
/normalize-path@3.0.0:
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
engines: {node: '>=0.10.0'}
dev: true
/object-assign@4.1.1:
resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
engines: {node: '>=0.10.0'}
dev: false
/object-inspect@1.13.1:
resolution: {integrity: sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==}
dev: false
/on-finished@2.4.1:
resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}
engines: {node: '>= 0.8'}
dependencies:
ee-first: 1.1.1
dev: false
/parseurl@1.3.3:
resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}
engines: {node: '>= 0.8'}
dev: false
/path-to-regexp@0.1.7:
resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==}
dev: false
/picomatch@2.3.1:
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
engines: {node: '>=8.6'}
dev: true
/proxy-addr@2.0.7:
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
engines: {node: '>= 0.10'}
dependencies:
forwarded: 0.2.0
ipaddr.js: 1.9.1
dev: false
/pstree.remy@1.1.8:
resolution: {integrity: sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==}
dev: true
/qs@6.11.0:
resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==}
engines: {node: '>=0.6'}
dependencies:
side-channel: 1.0.6
dev: false
/range-parser@1.2.1:
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
engines: {node: '>= 0.6'}
dev: false
/raw-body@2.5.2:
resolution: {integrity: sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==}
engines: {node: '>= 0.8'}
dependencies:
bytes: 3.1.2
http-errors: 2.0.0
iconv-lite: 0.4.24
unpipe: 1.0.0
dev: false
/readdirp@3.6.0:
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
engines: {node: '>=8.10.0'}
dependencies:
picomatch: 2.3.1
dev: true
/redis-errors@1.2.0:
resolution: {integrity: sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==}
engines: {node: '>=4'}
dev: false
/redis-parser@3.0.0:
resolution: {integrity: sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==}
engines: {node: '>=4'}
dependencies:
redis-errors: 1.2.0
dev: false
/safe-buffer@5.2.1:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
dev: false
/safer-buffer@2.1.2:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
dev: false
/semver@7.6.2:
resolution: {integrity: sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==}
engines: {node: '>=10'}
hasBin: true
dev: true
/send@0.18.0:
resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==}
engines: {node: '>= 0.8.0'}
dependencies:
debug: 2.6.9
depd: 2.0.0
destroy: 1.2.0
encodeurl: 1.0.2
escape-html: 1.0.3
etag: 1.8.1
fresh: 0.5.2
http-errors: 2.0.0
mime: 1.6.0
ms: 2.1.3
on-finished: 2.4.1
range-parser: 1.2.1
statuses: 2.0.1
transitivePeerDependencies:
- supports-color
dev: false
/seq-queue@0.0.5:
resolution: {integrity: sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q==}
dev: false
/serve-static@1.15.0:
resolution: {integrity: sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==}
engines: {node: '>= 0.8.0'}
dependencies:
encodeurl: 1.0.2
escape-html: 1.0.3
parseurl: 1.3.3
send: 0.18.0
transitivePeerDependencies:
- supports-color
dev: false
/set-function-length@1.2.2:
resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==}
engines: {node: '>= 0.4'}
dependencies:
define-data-property: 1.1.4
es-errors: 1.3.0
function-bind: 1.1.2
get-intrinsic: 1.2.4
gopd: 1.0.1
has-property-descriptors: 1.0.2
dev: false
/setprototypeof@1.2.0:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
dev: false
/side-channel@1.0.6:
resolution: {integrity: sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==}
engines: {node: '>= 0.4'}
dependencies:
call-bind: 1.0.7
es-errors: 1.3.0
get-intrinsic: 1.2.4
object-inspect: 1.13.1
dev: false
/simple-update-notifier@2.0.0:
resolution: {integrity: sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==}
engines: {node: '>=10'}
dependencies:
semver: 7.6.2
dev: true
/sqlstring@2.3.3:
resolution: {integrity: sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==}
engines: {node: '>= 0.6'}
dev: false
/standard-as-callback@2.1.0:
resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==}
dev: false
/statuses@2.0.1:
resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==}
engines: {node: '>= 0.8'}
dev: false
/supports-color@5.5.0:
resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
engines: {node: '>=4'}
dependencies:
has-flag: 3.0.0
/to-regex-range@5.0.1:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
dependencies:
is-number: 7.0.0
dev: true
/toidentifier@1.0.1:
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
engines: {node: '>=0.6'}
dev: false
/touch@3.1.1:
resolution: {integrity: sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==}
hasBin: true
dev: true
/ts-node@10.9.2(@types/node@20.12.12)(typescript@5.4.5):
resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==}
hasBin: true
peerDependencies:
'@swc/core': '>=1.2.50'
'@swc/wasm': '>=1.2.50'
'@types/node': '*'
typescript: '>=2.7'
peerDependenciesMeta:
'@swc/core':
optional: true
'@swc/wasm':
optional: true
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.11
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.4
'@types/node': 20.12.12
acorn: 8.11.3
acorn-walk: 8.3.2
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
typescript: 5.4.5
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
dev: true
/type-is@1.6.18:
resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==}
engines: {node: '>= 0.6'}
dependencies:
media-typer: 0.3.0
mime-types: 2.1.35
dev: false
/typescript@5.4.5:
resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==}
engines: {node: '>=14.17'}
hasBin: true
dev: true
/undefsafe@2.0.5:
resolution: {integrity: sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==}
dev: true
/undici-types@5.26.5:
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
dev: true
/unpipe@1.0.0:
resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}
engines: {node: '>= 0.8'}
dev: false
/utils-merge@1.0.1:
resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==}
engines: {node: '>= 0.4.0'}
dev: false
/v8-compile-cache-lib@3.0.1:
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
dev: true
/vary@1.1.2:
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
engines: {node: '>= 0.8'}
dev: false
/yn@3.1.1:
resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
engines: {node: '>=6'}
dev: true

View File

@@ -1,14 +0,0 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@plugs/*": ["plugs/*"],
"@apis/*": ["apis/*"]
}
}
}

View File

@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};

56
tone-page-server/.gitignore vendored Normal file
View File

@@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build
# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# OS
.DS_Store
# Tests
/coverage
/.nyc_output
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# temp directory
.temp
.tmp
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

View File

@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

View File

@@ -0,0 +1,99 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
## Project setup
```bash
$ pnpm install
```
## Compile and run the project
```bash
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod
```
## Run tests
```bash
# unit tests
$ pnpm run test
# e2e tests
$ pnpm run test:e2e
# test coverage
$ pnpm run test:cov
```
## Deployment
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
```bash
$ pnpm install -g mau
$ mau deploy
```
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
## Resources
Check out a few resources that may come in handy when working with NestJS:
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).

View File

@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}

View File

@@ -0,0 +1,91 @@
{
"name": "tone-page-server",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@alicloud/credentials": "^2.4.3",
"@alicloud/dm20151123": "1.2.6",
"@alicloud/dysmsapi20170525": "4.1.0",
"@alicloud/openapi-client": "^0.4.14",
"@alicloud/tea-util": "^1.4.10",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^10.0.0",
"@nestjs/jwt": "^11.0.0",
"@nestjs/mapped-types": "*",
"@nestjs/passport": "^11.0.5",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/throttler": "^6.4.0",
"@nestjs/typeorm": "^11.0.0",
"@types/ali-oss": "^6.16.11",
"ali-oss": "^6.23.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.2",
"jsonwebtoken": "^9.0.2",
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"pg": "^8.15.6",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
"typeorm": "^0.3.22",
"uuid": "^11.1.0"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.1",
"@types/passport-jwt": "^4.0.1",
"@types/supertest": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"prettier": "^3.0.0",
"source-map-support": "^0.5.21",
"supertest": "^7.0.0",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}

7218
tone-page-server/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AdminController } from './admin.controller';
describe('AdminController', () => {
let controller: AdminController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [AdminController],
}).compile();
controller = module.get<AdminController>(AdminController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';
@Controller('admin')
export class AdminController {}

View File

@@ -0,0 +1,26 @@
import { Module } from '@nestjs/common';
import { AdminController } from './admin.controller';
import { AdminUserController } from './controller/admin-user.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from 'src/user/entities/user.entity';
import { UserModule } from 'src/user/user.module';
import { AdminWebResourceController } from './controller/web/admin-web-resource.controller';
import { AdminWebBlogController } from './controller/web/admin-web-blog.controller';
import { ResourceModule } from 'src/resource/resource.module';
import { BlogModule } from 'src/blog/blog.module';
@Module({
imports: [
TypeOrmModule.forFeature([User]),
UserModule,
ResourceModule,
BlogModule,
],
controllers: [
AdminController,
AdminUserController,
AdminWebResourceController,
AdminWebBlogController,
],
})
export class AdminModule {}

View File

@@ -0,0 +1,83 @@
import {
Body,
Controller,
Delete,
Get,
Param,
ParseUUIDPipe,
Post,
Put,
Query,
UseGuards,
} from '@nestjs/common';
import { ListDto } from '../dto/admin-user/list.dto';
import { CreateDto } from '../dto/admin-user/create.dto';
import { UserService } from 'src/user/user.service';
import { UpdateDto } from '../dto/admin-user/update.dto';
import { UpdatePasswordDto } from '../dto/admin-user/update-password.dto';
import { RemoveUserDto } from '../dto/admin-user/remove.dto';
import { RolesGuard } from 'src/common/guard/roles.guard';
import { Roles } from 'src/common/decorators/role.decorator';
import { Role } from 'src/auth/role.enum';
import { AuthGuard } from '@nestjs/passport';
@Controller('admin/user')
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(Role.Admin)
export class AdminUserController {
constructor(private readonly userService: UserService) {}
@Get()
async list(@Query() listDto: ListDto) {
return this.userService.list(listDto.page, listDto.pageSize);
}
@Get(':userId')
async get(
@Param('userId', new ParseUUIDPipe({ version: '4' })) userId: string,
) {
return this.userService.findOne({ userId });
}
@Post()
async create(@Body() createDto: CreateDto) {
return this.userService.create({
...createDto,
...(createDto.password &&
(() => {
const salt = this.userService.generateSalt();
return {
salt,
password_hash: this.userService.hashPassword(
createDto.password,
salt,
),
};
})()),
});
}
@Put(':userId')
async update(
@Param('userId', new ParseUUIDPipe({ version: '4' })) userId: string,
@Body() updateDto: UpdateDto,
) {
return this.userService.update(userId, updateDto);
}
@Delete(':userId')
async delete(
@Param('userId', new ParseUUIDPipe({ version: '4' })) userId: string,
@Query() dto: RemoveUserDto,
) {
return this.userService.delete(userId, dto.soft);
}
@Post(':userId/password')
async setPassword(
@Param('userId', new ParseUUIDPipe({ version: '4' })) userId: string,
@Body() updatePasswordDto: UpdatePasswordDto,
) {
return this.userService.setPassword(userId, updatePasswordDto.password);
}
}

View File

@@ -0,0 +1,64 @@
import {
Body,
Controller,
Delete,
Get,
Param,
ParseUUIDPipe,
Post,
Put,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { CreateBlogDto } from 'src/admin/dto/admin-web/create-blog.dto';
import { SetBlogPasswordDto } from 'src/admin/dto/admin-web/set-blog-password.dto';
import { UpdateBlogDto } from 'src/admin/dto/admin-web/update-blog.dto';
import { Role } from 'src/auth/role.enum';
import { BlogService } from 'src/blog/blog.service';
import { Roles } from 'src/common/decorators/role.decorator';
import { RolesGuard } from 'src/common/guard/roles.guard';
@Controller('/admin/web/blog')
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(Role.Admin)
export class AdminWebBlogController {
constructor(private readonly adminWebBlogService: BlogService) {}
@Get()
async list() {
return this.adminWebBlogService.list({
withAll: true,
});
}
@Post()
async create(@Body() dto: CreateBlogDto) {
return this.adminWebBlogService.create(dto);
}
@Put(':id')
async update(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
@Body() dto: UpdateBlogDto,
) {
return this.adminWebBlogService.update(id, dto);
}
@Post(':id/password')
async setPassword(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
@Body() dto: SetBlogPasswordDto,
) {
return this.adminWebBlogService.setPassword(id, dto.password);
}
@Get(':id')
async get(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
return this.adminWebBlogService.findById(id);
}
@Delete(':id')
async remove(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
return this.adminWebBlogService.remove(id);
}
}

View File

@@ -0,0 +1,52 @@
import {
Body,
Controller,
Delete,
Get,
Param,
ParseUUIDPipe,
Post,
Put,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { CreateResourceDto } from 'src/admin/dto/admin-web/create-resource.dto';
import { Role } from 'src/auth/role.enum';
import { Roles } from 'src/common/decorators/role.decorator';
import { RolesGuard } from 'src/common/guard/roles.guard';
import { ResourceService } from 'src/resource/resource.service';
@Controller('/admin/web/resource')
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(Role.Admin)
export class AdminWebResourceController {
constructor(private readonly resourceService: ResourceService) {}
@Get()
async list() {
return this.resourceService.findAll();
}
@Get(':id')
async get(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
return this.resourceService.findById(id);
}
@Post()
async create(@Body() data: CreateResourceDto) {
return this.resourceService.create(data);
}
@Put(':id')
async update(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
@Body() data: CreateResourceDto,
) {
return this.resourceService.update(id, data);
}
@Delete(':id')
async delete(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
return this.resourceService.delete(id);
}
}

View File

@@ -0,0 +1,9 @@
import { IsString } from 'class-validator';
export class CreatePermissionDto {
@IsString()
name: string;
@IsString()
description: string;
}

View File

@@ -0,0 +1,8 @@
import { ArrayMinSize, IsArray, IsUUID } from 'class-validator';
export class DeleteRolePermissionsDto {
@IsArray()
@ArrayMinSize(1)
@IsUUID('4', { each: true })
permissionIds: string[];
}

View File

@@ -0,0 +1,8 @@
import { ArrayMinSize, IsArray, IsUUID } from 'class-validator';
export class SetRolePermissionsDto {
@IsArray()
@ArrayMinSize(1)
@IsUUID('4', { each: true })
permissionIds: string[];
}

View File

@@ -0,0 +1,9 @@
import { IsString } from 'class-validator';
export class CreateRoleDto {
@IsString()
name: string;
@IsString()
localName: string;
}

View File

@@ -0,0 +1,13 @@
import { IsBoolean, IsDateString, IsOptional, IsUUID } from 'class-validator';
export class CreateUserRoleDto {
@IsUUID('4')
roleId: string;
@IsBoolean()
isEnabled: boolean;
@IsOptional()
@IsDateString()
expiredAt?: Date;
}

View File

@@ -0,0 +1,6 @@
import { IsUUID } from 'class-validator';
export class DeleteUserRoleDto {
@IsUUID('4')
roleId: string;
}

View File

@@ -0,0 +1,32 @@
import { IsString, Length, Matches, ValidateIf } from 'class-validator';
export class CreateDto {
@ValidateIf((o) => o.username !== null)
@IsString({ message: '用户名不得为空' })
@Length(4, 32, { message: '用户名长度只能为4~32' })
username: string | null;
@ValidateIf((o) => o.nickname !== null)
@IsString({ message: '昵称不得为空' })
@Length(1, 30, { message: '昵称长度只能为1~30' })
nickname: string | null;
@ValidateIf((o) => o.email !== null)
@IsString({ message: '邮箱不得为空' })
@Length(6, 254, { message: '邮箱长度只能为6~254' })
email: string | null;
@ValidateIf((o) => o.phone !== null)
@IsString({ message: '手机号不得为空' })
@Length(11, 11, { message: '手机号长度只能为11' })
phone: string | null;
@ValidateIf((o) => o.password !== null)
@IsString({ message: '密码不得为空' })
@Length(6, 32, { message: '密码长度只能为6~32' })
@Matches(
/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/,
{ message: '密码必须包含字母和数字且长度在6~32之间' },
)
password: string | null;
}

View File

@@ -0,0 +1,3 @@
import { PaginationDto } from '../common/pagination.dto';
export class ListDto extends PaginationDto {}

View File

@@ -0,0 +1,8 @@
import { Transform } from 'class-transformer';
import { IsBoolean } from 'class-validator';
export class RemoveUserDto {
@Transform(({ value }) => value === 'true')
@IsBoolean({ message: '需指定删除类型' })
soft: boolean;
}

View File

@@ -0,0 +1,11 @@
import { IsString, Length, Matches } from 'class-validator';
export class UpdatePasswordDto {
@IsString({ message: '密码不得为空' })
@Length(6, 32, { message: '密码长度只能为6~32' })
@Matches(
/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/,
{ message: '密码必须包含字母和数字且长度在6~32之间' },
)
password: string;
}

View File

@@ -0,0 +1,35 @@
import {
IsEmail,
IsOptional,
IsString,
Length,
Matches,
} from 'class-validator';
export class UpdateDto {
@IsString({ message: '用户名不得为空' })
@Length(4, 32, { message: '用户名长度只能为4~32' })
username: string;
@IsString({ message: '昵称不得为空' })
@Length(1, 30, { message: '昵称长度只能为1~30' })
nickname: string;
@IsOptional()
@IsEmail({}, { message: '请输入有效的邮箱地址', always: false })
@Length(6, 254, {
message: '邮箱长度只能为6~254',
// 仅在值不为 null 或 undefined 时验证
always: false,
})
email?: string;
@IsOptional() // 标记字段为可选
@IsString({ message: '手机号不得为空', always: false })
@Matches(/^1[3456789]\d{9}$/, {
message: '请输入有效的手机号码',
// 仅在值不为 null 或 undefined 时验证
always: false,
})
phone?: string;
}

View File

@@ -0,0 +1,19 @@
import { IsEnum, IsString } from 'class-validator';
import { BlogPermission } from 'src/blog/bloga.permission.enum';
export class CreateBlogDto {
@IsString()
title: string;
@IsString()
description: string;
@IsString()
contentUrl: string;
@IsEnum(BlogPermission, { each: true, message: '请求类型错误' })
permissions: BlogPermission[];
@IsString()
password: string; // 允许空串
}

View File

@@ -0,0 +1,28 @@
import { Type } from 'class-transformer';
import { IsString, ValidateNested } from 'class-validator';
class ResourceTagDto {
@IsString()
name: string;
@IsString()
type: string;
}
export class CreateResourceDto {
@IsString()
title: string;
@IsString()
description: string;
@IsString()
imageUrl: string;
@IsString()
link: string;
@ValidateNested({ each: true })
@Type(() => ResourceTagDto)
tags: ResourceTagDto[];
}

View File

@@ -0,0 +1,6 @@
import { IsString } from 'class-validator';
export class SetBlogPasswordDto {
@IsString()
password: string;
}

View File

@@ -0,0 +1,16 @@
import { IsEnum, IsString } from 'class-validator';
import { BlogPermission } from 'src/blog/bloga.permission.enum';
export class UpdateBlogDto {
@IsString()
title: string;
@IsString()
description: string;
@IsString()
contentUrl: string;
@IsEnum(BlogPermission, { each: true, message: '请求类型错误' })
permissions: BlogPermission[];
}

View File

@@ -0,0 +1,16 @@
import { Type } from 'class-transformer';
import { IsInt, IsOptional, Min } from 'class-validator';
export class PaginationDto {
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
page?: number = 1;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
pageSize?: number = 20;
}

View File

@@ -0,0 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
describe('AppController', () => {
let appController: AppController;
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
appController = app.get<AppController>(AppController);
});
describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
});
});
});

View File

@@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}

View File

@@ -0,0 +1,52 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserModule } from './user/user.module';
import { AuthModule } from './auth/auth.module';
import { VerificationModule } from './verification/verification.module';
import { NotificationModule } from './notification/notification.module';
import { PassportModule } from '@nestjs/passport';
import { ResourceModule } from './resource/resource.module';
import { BlogModule } from './blog/blog.module';
import { AdminModule } from './admin/admin.module';
import { OssModule } from './oss/oss.module';
import { ThrottlerModule } from '@nestjs/throttler';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
TypeOrmModule.forRoot({
type: 'postgres',
host: process.env.DATABASE_HOST,
port: parseInt(process.env.DATABASE_PORT, 10) || 5432,
username: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_NAME,
autoLoadEntities: true,
entities: [],
synchronize: process.env.NODE_ENV !== 'production', // Set to false in production
}),
PassportModule.register({ defaultStrategy: 'jwt' }),
ThrottlerModule.forRoot({
throttlers: [
{
limit: 1000,
ttl: 60000, // 1 minute
},
],
}),
UserModule,
AuthModule,
VerificationModule,
NotificationModule,
ResourceModule,
BlogModule,
AdminModule,
OssModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}

View File

@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AuthController } from './auth.controller';
describe('AuthController', () => {
let controller: AuthController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [AuthController],
}).compile();
controller = module.get<AuthController>(AuthController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -0,0 +1,46 @@
import {
BadRequestException,
Body,
Controller,
Post,
Request,
UseGuards,
} from '@nestjs/common';
import { LoginDto } from './dto/login.dto';
import { AuthService } from './auth.service';
import { AuthGuard } from '@nestjs/passport';
import { UserSessionService } from 'src/user/services/user-session.service';
import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
@Controller('auth')
export class AuthController {
constructor(
private readonly authService: AuthService,
private readonly userSessionService: UserSessionService,
) {}
@Post('login')
@UseGuards(ThrottlerGuard)
@Throttle({ default: { limit: 20, ttl: 60000 } })
async login(@Body() loginDto: LoginDto) {
switch (loginDto.type) {
case 'password':
return this.authService.loginWithPassword(loginDto);
case 'phone':
return this.authService.loginWithPhone(loginDto);
case 'email':
return this.authService.loginWithEmail(loginDto);
default:
throw new BadRequestException('服务器错误');
}
}
@UseGuards(AuthGuard('jwt'))
@Post('logout')
async logout(@Request() req) {
const { userId, sessionId } = req.user;
await this.userSessionService.invalidateSession(userId, sessionId);
return true;
}
}

View File

@@ -0,0 +1,36 @@
import { forwardRef, Module } from '@nestjs/common';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
import { UserModule } from 'src/user/user.module';
import { JwtModule } from '@nestjs/jwt';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserSession } from 'src/user/entities/user-session.entity';
import { PassportModule } from '@nestjs/passport';
import { JwtStrategy } from './strategies/jwt.strategy';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { VerificationModule } from 'src/verification/verification.module';
import { OptionalAuthGuard } from './strategies/OptionalAuthGuard';
@Module({
imports: [
ConfigModule,
forwardRef(() => UserModule),
TypeOrmModule.forFeature([UserSession]),
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.registerAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
secret: configService.get<string>('JWT_SECRET', 'tone-page'),
signOptions: {
expiresIn: configService.get<string>('JWT_EXPIRES_IN', '1d'),
},
}),
}),
VerificationModule,
],
controllers: [AuthController],
providers: [AuthService, JwtStrategy, OptionalAuthGuard],
exports: [PassportModule, JwtStrategy, AuthService, OptionalAuthGuard],
})
export class AuthModule {}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AuthService } from './auth.service';
describe('AuthService', () => {
let service: AuthService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [AuthService],
}).compile();
service = module.get<AuthService>(AuthService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -0,0 +1,155 @@
import { createHash } from 'crypto';
import { BadRequestException, Injectable } from '@nestjs/common';
import { LoginDto } from './dto/login.dto';
import { UserService } from 'src/user/user.service';
import { User } from 'src/user/entities/user.entity';
import { JwtService } from '@nestjs/jwt';
import { UserSessionService } from 'src/user/services/user-session.service';
import { v4 as uuidv4 } from 'uuid';
import { VerificationService } from 'src/verification/verification.service';
@Injectable()
export class AuthService {
constructor(
private readonly userService: UserService,
private readonly jwtService: JwtService,
private readonly userSessionService: UserSessionService,
private readonly verificationService: VerificationService,
) {}
async loginWithPassword(loginDto: LoginDto) {
const { account, password } = loginDto;
// 依次使用邮箱登录、手机号、账号
const user = await this.userService.findOne(
[{ email: account }, { phone: account }, { username: account }],
{
withDeleted: true,
},
);
if (user && user.deletedAt !== null) {
throw new BadRequestException('该账号注销中');
}
if (user === null || !user.password_hash || !user.salt) {
throw new BadRequestException('账户或密码错误');
}
// 判断密码是否正确
const hashedPassword = this.hashPassword(password, user.salt);
if (hashedPassword !== user.password_hash) {
throw new BadRequestException('账户或密码错误');
}
// 登录成功颁发token
return {
token: await this.generateToken(user),
};
}
async loginWithPhone(loginDto: LoginDto) {
const { phone, code } = loginDto;
// 先判断验证码是否正确
const isValid = this.verificationService.verifyPhoneCode(
phone,
code,
'login',
);
switch (isValid) {
case 0:
break;
case -1:
throw new BadRequestException('验证码已过期');
case -2:
throw new BadRequestException('验证码错误');
case -3:
throw new BadRequestException('验证码已失效');
default:
throw new BadRequestException('验证码错误');
}
// 判断用户是否存在,若不存在则进行注册
let user = await this.userService.findOne({ phone }, { withDeleted: true });
if (user && user.deletedAt !== null) {
throw new BadRequestException('该账号注销中,请使用其他手机号');
}
if (!user) {
// 执行注册操作
user = await this.userService.create({ phone: phone });
}
if (!user || !user.userId) {
// 注册失败或用户信息错误
throw new BadRequestException('请求失败,请稍后再试');
}
// 登录颁发token
return {
token: await this.generateToken(user),
};
}
async loginWithEmail(loginDto: LoginDto) {
const { email, code } = loginDto;
// 先判断验证码是否正确
const isValid = this.verificationService.verifyEmailCode(
email,
code,
'login',
);
switch (isValid) {
case 0:
break;
case -1:
throw new BadRequestException('验证码已过期,请重新获取');
case -2:
throw new BadRequestException('验证码错误');
case -3:
throw new BadRequestException('验证码已失效,请重新获取');
default:
throw new BadRequestException('验证码错误,请稍后再试');
}
// 判断用户是否存在,若不存在则进行注册
let user = await this.userService.findOne({ email }, { withDeleted: true });
if (user && user.deletedAt !== null) {
throw new BadRequestException('该账号注销中,请使用其他邮箱');
}
if (!user) {
// 执行注册操作
user = await this.userService.create({ email: email });
}
if (!user || !user.userId) {
// 注册失败或用户信息错误
throw new BadRequestException('请求失败,请稍后再试');
}
// 登录颁发token
return {
token: await this.generateToken(user),
};
}
private hashPassword(password: string, salt: string): string {
return createHash('sha256').update(`${password}${salt}`).digest('hex');
}
private async generateToken(user: User) {
const payload = {
userId: user.userId,
sessionId: uuidv4(),
};
// 存储
await this.userSessionService.createSession(
payload.userId,
payload.sessionId,
);
// 颁发token
return this.jwtService.sign(payload);
}
}

View File

@@ -0,0 +1,31 @@
import { IsEnum, IsString, Length, ValidateIf } from 'class-validator';
export class LoginDto {
@IsEnum(['password', 'phone', 'email'], { message: '请求类型错误' })
type: 'password' | 'phone' | 'email';
@ValidateIf((o) => o.type === 'password')
@IsString({ message: '账户必须输入' })
@Length(1, 254, { message: '账户异常' }) // 用户名、邮箱、手机号
account?: string;
@ValidateIf((o) => o.type === 'password')
@IsString({ message: '密码必须输入' })
@Length(6, 32, { message: '密码异常' }) // 6-32位
password?: string;
@ValidateIf((o) => o.type === 'phone')
@IsString({ message: '手机号必须输入' })
@Length(11, 11, { message: '手机号异常' }) // 中国大陆11位数字
phone?: string;
@ValidateIf((o) => o.type === 'email')
@IsString({ message: '邮箱必须输入' })
@Length(6, 254, { message: '邮箱异常' }) // RFC 5321
email?: string;
@ValidateIf((o) => o.type === 'phone' || o.type === 'email')
@IsString({ message: '验证码必须输入' })
@Length(6, 6, { message: '验证码异常' }) // 6位数字
code?: string;
}

View File

@@ -0,0 +1,3 @@
export enum Role {
Admin = 'admin',
}

View File

@@ -0,0 +1,28 @@
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
@Injectable()
export class OptionalAuthGuard extends AuthGuard('jwt') implements CanActivate {
async canActivate(context: ExecutionContext): Promise<boolean> {
try {
await super.canActivate(context);
return true;
} catch (error) {
console.error('OptionalAuthGuard error:', error);
return true; // 如果验证失败,仍然允许访问
}
}
handleRequest<TUser = any>(
err: any,
user: any,
// info: any,
// context: ExecutionContext,
// status?: any,
): TUser {
if (err || !user) {
return null; // 如果没有用户信息返回null
}
return user; // 如果有用户信息,返回用户对象
}
}

View File

@@ -0,0 +1,47 @@
import {
BadRequestException,
Injectable,
UnauthorizedException,
} from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';
import { UserSessionService } from 'src/user/services/user-session.service';
import { UserService } from 'src/user/user.service';
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
constructor(
private readonly userService: UserService,
private readonly userSessionService: UserSessionService,
private readonly configService: ConfigService,
) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: false,
secretOrKey: configService.get<string>('JWT_SECRET', 'tone-page'),
});
}
async validate(payload: any) {
const { userId, sessionId } = payload ?? {};
const isValidSession = await this.userSessionService.isSessionValid(
userId,
sessionId,
);
if (!isValidSession) {
throw new UnauthorizedException('登录凭证已过期,请重新登录');
}
const user = await this.userService.findById(userId);
if (!user) {
throw new BadRequestException('用户不存在');
}
return {
...user,
sessionId,
};
}
}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { BlogController } from './blog.controller';
describe('BlogController', () => {
let controller: BlogController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [BlogController],
}).compile();
controller = module.get<BlogController>(BlogController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -0,0 +1,124 @@
import {
BadRequestException,
Body,
Controller,
Get,
Param,
ParseUUIDPipe,
Post,
Query,
Req,
UseGuards,
} from '@nestjs/common';
import { BlogService } from './blog.service';
import { OptionalAuthGuard } from 'src/auth/strategies/OptionalAuthGuard';
import { UserService } from 'src/user/user.service';
import { createBlogCommentDto } from './dto/create.blogcomment.dto';
import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
import { BlogPermission } from './blog.permission.enum';
@Controller('blog')
export class BlogController {
constructor(
private readonly blogService: BlogService,
private readonly userService: UserService,
) {}
@Get()
getBlogs() {
return this.blogService.list();
}
@Get(':id')
async getBlog(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
@Query('p') password?: string,
) {
const blog = await this.blogService.findById(id);
if (!blog) throw new BadRequestException('文章不存在或无权限访问');
if (!blog.permissions.includes(BlogPermission.Public)) {
// 无公开权限,则进一步检查是否有密码保护
if (!blog.permissions.includes(BlogPermission.ByPassword)) {
throw new BadRequestException('文章不存在或无权限访问');
} else {
// 判断密码是否正确
if (
!password ||
this.blogService.hashPassword(password) !== blog.password_hash
) {
throw new BadRequestException('文章不存在或无权限访问');
}
}
}
const blogDataRes = await fetch(`${blog.contentUrl}`);
const blogContent = await blogDataRes.text();
await this.blogService.incrementViewCount(id);
return {
id: blog.id,
title: blog.title,
createdAt: blog.createdAt,
content: blogContent,
};
}
@Get(':id/comments')
async getBlogComments(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
) {
const blog = await this.blogService.findById(id);
if (!blog) throw new BadRequestException('文章不存在');
return await this.blogService.getComments(id);
}
// 该接口允许匿名评论但仍需验证userId合法性
@UseGuards(ThrottlerGuard, OptionalAuthGuard)
@Throttle({ default: { limit: 5, ttl: 60000 } })
@Post(':id/comment')
async createBlogComment(
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
@Body() commentData: createBlogCommentDto,
@Req() req,
) {
const { userId } = req.user || {};
const blog = await this.blogService.findById(id);
if (!blog) throw new BadRequestException('文章不存在');
const user = userId ? await this.userService.findById(userId) : null;
const ip = req.headers['x-forwarded-for'] || req.ip;
// 获取IP归属地
let address = '未知';
if (!['::1'].includes(ip)) {
const addressRes = await (
await fetch(
`https://mesh.if.iqiyi.com/aid/ip/info?version=1.1.1&ip=${ip}`,
)
).json();
if (addressRes?.code == 0) {
const country: string = addressRes?.data?.countryCN || '未知';
const province: string = addressRes?.data?.provinceCN || '中国';
if (country !== '中国') {
// 非中国,显示国家
address = country;
} else {
// 中国,显示省份
address = province;
}
}
}
const comment = {
...commentData,
blog,
user,
ip,
address,
};
return await this.blogService.createComment(comment);
}
}

View File

@@ -0,0 +1,20 @@
import { Module } from '@nestjs/common';
import { BlogController } from './blog.controller';
import { BlogService } from './blog.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Blog } from './entity/Blog.entity';
import { BlogComment } from './entity/BlogComment.entity';
import { AuthModule } from 'src/auth/auth.module';
import { UserModule } from 'src/user/user.module';
@Module({
imports: [
TypeOrmModule.forFeature([Blog, BlogComment]),
AuthModule,
UserModule,
],
controllers: [BlogController],
providers: [BlogService],
exports: [BlogService],
})
export class BlogModule {}

View File

@@ -0,0 +1,5 @@
export enum BlogPermission {
Public = 'Public',
ByPassword = 'ByPassword',
List = 'List',
}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { BlogService } from './blog.service';
describe('BlogService', () => {
let service: BlogService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [BlogService],
}).compile();
service = module.get<BlogService>(BlogService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -0,0 +1,121 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Blog } from './entity/Blog.entity';
import { Repository } from 'typeorm';
import { BlogComment } from './entity/BlogComment.entity';
import { BlogPermission } from './blog.permission.enum';
import { createHash } from 'crypto';
@Injectable()
export class BlogService {
constructor(
@InjectRepository(Blog)
private readonly blogRepository: Repository<Blog>,
@InjectRepository(BlogComment)
private readonly blogCommentRepository: Repository<BlogComment>,
) {}
async list(
option: {
withAll?: boolean;
} = {},
) {
return (
await this.blogRepository.find({
order: {
createdAt: 'DESC',
},
})
)
.filter(
(i) => option.withAll || i.permissions.includes(BlogPermission.List),
)
.map((i) => {
if (option.withAll) {
return i;
}
const { createdAt, deletedAt, id, title, viewCount } = i;
return {
createdAt,
deletedAt,
id,
title,
viewCount,
};
});
}
async create(dto: Partial<Blog> & { password: string }) {
const { password, ...blog } = dto;
if (blog.permissions.includes(BlogPermission.ByPassword)) {
if (password) {
blog.password_hash = createHash('sha256')
.update(`${password}`)
.digest('hex');
}
}
const newBlog = this.blogRepository.create(blog);
return this.blogRepository.save(newBlog);
}
async setPassword(id: string, password: string) {
const blog = await this.findById(id);
if (!blog) {
throw new Error('博客不存在');
}
return (
(
await this.blogRepository.update(id, {
...blog,
password_hash: this.hashPassword(password),
})
).affected > 0
);
}
async update(id: string, blog: Partial<Blog>) {
await this.blogRepository.update(id, blog);
return this.blogRepository.findOneBy({ id });
}
async remove(id: string) {
const blog = await this.blogRepository.findOneBy({ id });
if (!blog) return null;
return this.blogRepository.softRemove(blog);
}
async findById(id: string) {
return await this.blogRepository.findOneBy({ id });
}
async incrementViewCount(id: string) {
await this.blogRepository.increment({ id }, 'viewCount', 1);
}
async getComments(blogId: string) {
const blog = await this.findById(blogId);
if (!blog) {
throw new Error('文章不存在');
}
return this.blogCommentRepository.find({
where: { blog },
relations: ['user'],
order: {
createdAt: 'DESC',
},
});
}
async createComment(comment: Partial<BlogComment>) {
const newComment = this.blogCommentRepository.create(comment);
return this.blogCommentRepository.save(newComment);
}
hashPassword(password: string) {
return createHash('sha256').update(`${password}`).digest('hex');
}
}

View File

@@ -0,0 +1,10 @@
import { IsOptional, IsString, IsUUID } from 'class-validator';
export class createBlogCommentDto {
@IsString({ message: '评论内容不能为空' })
content: string;
@IsOptional()
@IsUUID('4', { message: '父评论ID格式错误' })
parentId?: string;
}

View File

@@ -0,0 +1,50 @@
import {
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
OneToMany,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { BlogComment } from './BlogComment.entity';
import { BlogPermission } from '../blog.permission.enum';
/** @todo 考虑后续将权限的数据类型替换为json以提高查询效率 */
@Entity()
export class Blog {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
title: string;
@Column()
description: string;
@Column()
contentUrl: string;
@Column({ default: 0 })
viewCount: number;
@CreateDateColumn({ precision: 3 })
createdAt: Date;
@UpdateDateColumn({ precision: 3 })
updatedAt: Date;
@DeleteDateColumn({ precision: 3, nullable: true })
deletedAt: Date;
// 权限
@Column('simple-array', { default: '' })
permissions: BlogPermission[];
@Column({ nullable: true })
password_hash: string | null;
// 关系
@OneToMany(() => BlogComment, (blog) => blog.id)
comments: BlogComment[];
}

View File

@@ -0,0 +1,43 @@
import { User } from 'src/user/entities/user.entity';
import {
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
} from 'typeorm';
import { Blog } from './Blog.entity';
@Entity()
export class BlogComment {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
content: string;
@Column()
ip: string;
@Column()
address: string;
@CreateDateColumn({ precision: 3 })
createdAt: Date;
@DeleteDateColumn({ precision: 3, nullable: true })
deletedAt: Date;
@ManyToOne(() => User, { nullable: true })
@JoinColumn({ name: 'userId' })
user: User | null;
@ManyToOne(() => Blog)
@JoinColumn({ name: 'blogId' })
blog: Blog | null;
@Column({ type: 'uuid', nullable: true })
parentId: string | null;
}

View File

@@ -0,0 +1,4 @@
import { SetMetadata } from '@nestjs/common';
import { Role } from 'src/auth/role.enum';
export const Roles = (...roles: Role[]) => SetMetadata('roles', roles);

View File

@@ -0,0 +1,37 @@
import {
BadRequestException,
CanActivate,
ExecutionContext,
ForbiddenException,
Injectable,
} from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { Role } from 'src/auth/role.enum';
import { User } from 'src/user/entities/user.entity';
@Injectable()
export class RolesGuard implements CanActivate {
constructor(private reflector: Reflector) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
const requiredRoles = this.reflector.getAllAndOverride<Role[] | undefined>(
'roles',
[context.getHandler(), context.getClass()],
);
if (!requiredRoles) return true;
const request = context.switchToHttp().getRequest();
const user = request.user as User | void;
if (!user) {
throw new BadRequestException('服务器内部错误');
}
if (!requiredRoles.some((role) => user.roles.includes(role))) {
throw new ForbiddenException('权限不足');
}
return true;
}
}

View File

@@ -0,0 +1,24 @@
import {
CallHandler,
ExecutionContext,
Injectable,
NestInterceptor,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
@Injectable()
export class ResponseInterceptor implements NestInterceptor {
intercept(
context: ExecutionContext,
next: CallHandler<any>,
): Observable<any> | Promise<Observable<any>> {
return next.handle().pipe(
map((data) => ({
statusCode: 200,
message: '请求成功',
data,
})),
);
}
}

View File

@@ -0,0 +1,31 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { BadRequestException, ValidationPipe } from '@nestjs/common';
import { ResponseInterceptor } from './common/interceptors/response.interceptor';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(
new ValidationPipe({
transform: true,
whitelist: true,
forbidNonWhitelisted: true,
stopAtFirstError: true,
exceptionFactory: (errors) => {
const error = errors[0];
const firstConstraint = error.constraints
? Object.values(error.constraints)[0]
: '验证失败';
throw new BadRequestException({
message: firstConstraint,
error: 'Bad Request',
statusCode: 400,
});
},
}),
);
app.useGlobalInterceptors(new ResponseInterceptor());
await app.listen(process.env.PORT ?? 3001);
}
bootstrap();

View File

@@ -0,0 +1,8 @@
import { Module } from '@nestjs/common';
import { NotificationService } from './notification.service';
@Module({
providers: [NotificationService],
exports: [NotificationService],
})
export class NotificationModule {}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { NotificationService } from './notification.service';
describe('NotificationService', () => {
let service: NotificationService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [NotificationService],
}).compile();
service = module.get<NotificationService>(NotificationService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -0,0 +1,142 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import Dm20151123, * as $Dm20151123 from '@alicloud/dm20151123';
import * as $OpenApi from '@alicloud/openapi-client';
// import Client, * as $dm from '@alicloud/dm20151123';
import * as $Util from '@alicloud/tea-util';
import Credential, { Config } from '@alicloud/credentials';
@Injectable()
export class NotificationService {
private dm: Dm20151123;
constructor() {
const credentialsConfig = new Config({
type: 'access_key',
accessKeyId: process.env.ALIYUN_ACCESS_KEY_ID,
accessKeySecret: process.env.ALIYUN_ACCESS_KEY_SECRET,
});
const credential = new Credential(credentialsConfig);
const config = new $OpenApi.Config({ credential });
config.endpoint = 'dm.aliyuncs.com';
this.dm = new Dm20151123(config);
}
private getMailHtmlBody(option: { type: 'login-verify'; code: string }) {
if (option.type === 'login-verify') {
return `<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>特恩的日志 - 登录验证码</title>
<style>
body { font-family: 'Helvetica Neue', Arial, sans-serif; line-height: 1.6; }
.container { max-width: 600px; margin: 0px auto; padding: 20px; }
.content { padding: 20px 0; }
.code-box {
background: #f8f9fa;
border: 1px dashed #ccc;
padding: 15px;
text-align: center;
margin: 20px 0;
font-size: 24px;
font-weight: bold;
letter-spacing: 5px;
color: #e74c3c;
}
.footer {
color: #777;
font-size: 12px;
border-top: 1px solid #eee;
padding-top: 15px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<p>您好!您正在尝试登录【特恩的日志】控制台,验证码如下:</p>
<div class="code-box">
<span id="verificationCode">${option.code}</span>
</div>
<p>请注意:</p>
<ul>
<li>此验证码 <strong>10分钟内</strong> 有效</li>
<li>请勿向任何人透露此验证码</li>
<li>如非本人操作,请忽略本邮件</li>
</ul>
</div>
<div class="footer">
<p>© 2025 TONE个人 版权所有</p>
<a href="https://beian.miit.gov.cn/">网站备案号渝ICP备2023009516号-1</a>
</div>
</div>
</body>
</html>`;
} else {
throw new Error('未配置的模版');
}
}
async sendMail(option: {
type: 'login-verify';
targetMail: string;
code: string;
}) {
const runtime = new $Util.RuntimeOptions({});
const singleSendMailRequest = new $Dm20151123.SingleSendMailRequest({
accountName: 'security@tonesc.cn',
addressType: 1,
replyToAddress: false,
toAddress: `${option.targetMail}`,
subject: '【特恩的日志】登陆验证码',
htmlBody: this.getMailHtmlBody({
type: 'login-verify',
code: option.code,
}),
textBody: '',
});
try {
await this.dm.singleSendMailWithOptions(singleSendMailRequest, runtime);
} catch (error) {
console.error(error);
throw new BadRequestException('邮件发送失败');
}
}
/**
* @deprecated 短信签名暂未通过
*/
async sendSMS(phone: string, type: 'login', code: string) {
throw new Error(
`SMS sending is not implemented yet. Phone: ${phone}, Type: ${type}, Code: ${code}`,
);
// const config = new $OpenApi.Config({
// accessKeyId: process.env.ALIYUN_ACCESS_KEY_ID,
// accessKeySecret: process.env.ALIYUN_ACCESS_KEY_SECRET,
// })
// config.endpoint = 'dysmsapi.aliyuncs.com';
// const client = new Client(config);
// const request = new $dysmsapi.SendSmsRequest({});
// request.phoneNumbers = phone;
// request.signName = (() => {
// switch (type) {
// case 'login':
// return process.env.ALIYUN_SMS_LOGIN_SIGN_NAME;
// default:
// throw new Error('Unknown SMS type');
// }
// })();
// request.templateCode = code;
// await client.sendSms(request).then(a => {
// console.log(a)
// }).catch(err => {
// console.error(err);
// })
}
}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { OssController } from './oss.controller';
describe('OssController', () => {
let controller: OssController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [OssController],
}).compile();
controller = module.get<OssController>(OssController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -0,0 +1,18 @@
import { Controller, Get, Request, UseGuards } from '@nestjs/common';
import { OssService } from './oss.service';
import { AuthGuard } from '@nestjs/passport';
@Controller('oss')
export class OssController {
constructor(private readonly ossService: OssService) {}
@UseGuards(AuthGuard('jwt'))
@Get('sts')
async getStsToken(@Request() req) {
const { userId } = req.user;
return {
...(await this.ossService.getStsToken(`${userId}`)),
userId,
};
}
}

View File

@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { OssService } from './oss.service';
import { OssController } from './oss.controller';
@Module({
providers: [OssService],
controllers: [OssController],
})
export class OssModule {}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { OssService } from './oss.service';
describe('OssService', () => {
let service: OssService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [OssService],
}).compile();
service = module.get<OssService>(OssService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -0,0 +1,53 @@
import { Injectable } from '@nestjs/common';
import { STS } from 'ali-oss';
@Injectable()
export class OssService {
private sts = new STS({
accessKeyId: process.env.ALIYUN_ACCESS_KEY_ID,
accessKeySecret: process.env.ALIYUN_ACCESS_KEY_SECRET,
});
private stsCache: {
[session: string]: {
credentials: {
AccessKeyId: string;
AccessKeySecret: string;
SecurityToken: string;
Expiration: string;
};
expireTime: number; // 时间戳,单位为毫秒
};
} = {};
/** @todo 该方法存在缓存穿透问题,待优化 */
async getStsToken(session: string) {
if (this.stsCache[session]) {
const cached = this.stsCache[session];
// 检查缓存是否过期
if (cached.expireTime > Date.now()) {
return cached.credentials;
} else {
// 如果过期,删除缓存
delete this.stsCache[session];
}
}
return this.sts
.assumeRole(process.env.ALIYUN_OSS_STS_ROLE_ARN, ``, 3600, `${session}`)
.then((res) => {
// 缓存
this.stsCache[session] = {
credentials: res.credentials,
expireTime:
new Date(res.credentials.Expiration).getTime() - 5 * 60 * 1000, // 提前5分钟过期,
};
return res.credentials;
})
.catch((err) => {
console.error('获取STS Token失败:', err);
throw new Error('获取STS Token失败');
});
}
}

View File

@@ -0,0 +1,41 @@
import {
Column,
CreateDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
type ResourceTag = {
name: string;
type: string;
};
@Entity()
export class Resource {
@PrimaryGeneratedColumn('uuid')
@Index()
id: string;
@Column()
title: string;
@Column()
description: string;
@Column()
imageUrl: string;
@Column()
link: string;
@Column('jsonb')
tags: ResourceTag[];
@CreateDateColumn({ precision: 3 })
createdAt: Date;
@UpdateDateColumn({ precision: 3 })
updatedAt: Date;
}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ResourceController } from './resource.controller';
describe('ResourceController', () => {
let controller: ResourceController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ResourceController],
}).compile();
controller = module.get<ResourceController>(ResourceController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { ResourceService } from './resource.service';
@Controller('resource')
export class ResourceController {
constructor(private readonly resourceService: ResourceService) {}
@Get()
async getResource() {
return this.resourceService.findAll();
}
}

View File

@@ -0,0 +1,13 @@
import { Module } from '@nestjs/common';
import { ResourceController } from './resource.controller';
import { ResourceService } from './resource.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Resource } from './entity/resource.entity';
@Module({
imports: [TypeOrmModule.forFeature([Resource])],
controllers: [ResourceController],
providers: [ResourceService],
exports: [ResourceService],
})
export class ResourceModule {}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ResourceService } from './resource.service';
describe('ResourceService', () => {
let service: ResourceService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [ResourceService],
}).compile();
service = module.get<ResourceService>(ResourceService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -0,0 +1,38 @@
import { Injectable } from '@nestjs/common';
import { Repository } from 'typeorm';
import { Resource } from './entity/resource.entity';
import { InjectRepository } from '@nestjs/typeorm';
@Injectable()
export class ResourceService {
constructor(
@InjectRepository(Resource)
private readonly resourceRepository: Repository<Resource>,
) {}
async findAll(): Promise<Resource[]> {
return this.resourceRepository.find({
order: {
createdAt: 'DESC',
},
});
}
async findById(id: string): Promise<Resource> {
return this.resourceRepository.findOne({ where: { id } });
}
async create(data: Partial<Resource>): Promise<Resource> {
const resource = this.resourceRepository.create(data);
return this.resourceRepository.save(resource);
}
async update(id: string, data: Partial<Resource>): Promise<Resource> {
await this.resourceRepository.update(id, data);
return this.resourceRepository.findOne({ where: { id } });
}
async delete(id: string): Promise<void> {
await this.resourceRepository.delete(id);
}
}

View File

@@ -0,0 +1,11 @@
import { IsString, Length, Matches } from 'class-validator';
export class UpdateUserPasswordDto {
@IsString({ message: '密码不得为空' })
@Length(6, 32, { message: '密码长度只能为6~32' })
@Matches(
/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/,
{ message: '密码必须包含字母和数字且长度在6~32之间' },
)
password: string;
}

View File

@@ -0,0 +1,31 @@
import {
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
} from 'typeorm';
@Entity()
@Index(['sessionId', 'userId'])
export class UserSession {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ length: 36 })
sessionId: string;
@Column({ length: 36 })
userId: string;
@CreateDateColumn({ precision: 3 })
createdAt: Date;
@DeleteDateColumn({ nullable: true, precision: 3 })
deletedAt: Date;
}
/**
* 考虑是否使用sessionId代替id以节省存储空间
*/

View File

@@ -0,0 +1,91 @@
import { Role } from 'src/auth/role.enum';
import {
BeforeInsert,
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { v4 as uuidv4 } from 'uuid';
@Entity()
@Index('IDX_user_userid', ['userId'], { unique: true })
@Index('IDX_user_username', ['username'], { unique: true })
@Index('IDX_user_email', ['email'], {
unique: true,
where: 'email IS NOT NULL',
})
@Index('IDX_user_phone', ['phone'], {
unique: true,
where: 'phone IS NOT NULL',
})
export class User {
@PrimaryGeneratedColumn('uuid')
userId: string;
@Column({ length: 32 })
username: string;
@Column({ length: 30 })
nickname: string;
@BeforeInsert()
generateDefaults() {
if (!this.username) {
this.username = `user_${uuidv4().replace(/-/g, '').slice(0, 27)}`;
}
if (!this.nickname) {
this.nickname = `用户_${uuidv4().replace(/-/g, '').slice(0, 8)}`;
}
}
@Column({ nullable: true, type: 'char', length: 32 })
salt: string;
@Column({ nullable: true, type: 'char', length: 64 })
password_hash: string;
@Column({
nullable: true,
length: 254,
transformer: {
to: (value: string | null) => value?.trim() || null,
from: (value: string | null) => value,
},
}) // RFC 5321
email: string | null;
@Column({
nullable: true,
length: 20,
transformer: {
to: (value: string | null) => value?.trim() || null,
from: (value: string | null) => value,
},
}) // China Mainland
phone: string | null;
@Column({
nullable: true,
transformer: {
to: (value: string | null) => value?.trim() || null,
from: (value: string | null) => value,
},
})
avatar: string;
@CreateDateColumn({ precision: 3 })
createdAt: Date;
@UpdateDateColumn({ precision: 3 })
updatedAt: Date;
@DeleteDateColumn({ nullable: true, precision: 3 })
deletedAt: Date;
@Column('simple-array', { default: '' })
roles: Role[];
}

View File

@@ -0,0 +1,46 @@
import { InjectRepository } from '@nestjs/typeorm';
import { Injectable } from '@nestjs/common';
import { UserSession } from '../entities/user-session.entity';
import { Repository } from 'typeorm';
@Injectable()
export class UserSessionService {
constructor(
@InjectRepository(UserSession)
private readonly userSessionRepository: Repository<UserSession>,
) {}
async createSession(userId: string, sessionId: string): Promise<UserSession> {
const session = this.userSessionRepository.create({
userId,
sessionId,
});
return await this.userSessionRepository.save(session);
}
async isSessionValid(userId: string, sessionId: string): Promise<boolean> {
const session = await this.userSessionRepository.findOne({
where: {
userId,
sessionId,
deletedAt: null,
},
});
return !!session;
}
async invalidateSession(userId: string, sessionId: string): Promise<void> {
const session = await this.userSessionRepository.findOne({
where: {
userId,
sessionId,
deletedAt: null,
},
});
if (session) {
await this.userSessionRepository.softDelete(session.id);
}
}
}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { UserController } from './user.controller';
describe('UserController', () => {
let controller: UserController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [UserController],
}).compile();
controller = module.get<UserController>(UserController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -0,0 +1,26 @@
import { Body, Controller, Get, Put, Request, UseGuards } from '@nestjs/common';
import { UserService } from './user.service';
import { AuthGuard } from '@nestjs/passport';
import { UpdateUserPasswordDto } from './dto/update-user-password.dto';
import { AuthService } from 'src/auth/auth.service';
@Controller('user')
export class UserController {
constructor(
private readonly userService: UserService,
private readonly authService: AuthService,
) {}
@UseGuards(AuthGuard('jwt'))
@Get('me')
async getMe(@Request() req) {
const { user } = req;
return this.userService.findOne({ userId: user.userId });
}
@UseGuards(AuthGuard('jwt'))
@Put('password')
async update(@Request() req, @Body() dto: UpdateUserPasswordDto) {
return this.userService.setPassword(req.user.userId, dto.password);
}
}

View File

@@ -0,0 +1,19 @@
import { forwardRef, Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from './entities/user.entity';
import { UserController } from './user.controller';
import { UserService } from './user.service';
import { UserSession } from './entities/user-session.entity';
import { AuthModule } from 'src/auth/auth.module';
import { UserSessionService } from './services/user-session.service';
@Module({
imports: [
TypeOrmModule.forFeature([User, UserSession]),
forwardRef(() => AuthModule), // 解决循环依赖问题
],
controllers: [UserController],
providers: [UserService, UserSessionService],
exports: [UserService, UserSessionService],
})
export class UserModule {}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { UserService } from './user.service';
describe('UserService', () => {
let service: UserService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [UserService],
}).compile();
service = module.get<UserService>(UserService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -0,0 +1,149 @@
import {
BadRequestException,
ConflictException,
Injectable,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { User } from './entities/user.entity';
import { QueryFailedError, Repository } from 'typeorm';
import { createHash } from 'crypto';
import { v4 as uuid } from 'uuid';
type UserFindOptions = Partial<
Pick<User, 'userId' | 'username' | 'phone' | 'email'>
>;
@Injectable()
export class UserService {
constructor(
@InjectRepository(User)
private readonly userRepository: Repository<User>,
) {}
/**
* @deprecated 尽量不使用该方法
*/
async findOne(
options: UserFindOptions | UserFindOptions[],
additionalOptions?: { withDeleted?: boolean },
): Promise<User | null> {
if (Object.keys(options).length === 0) {
throw new BadRequestException('查询条件不能为空');
}
return this.userRepository.findOne({
where: options,
withDeleted: additionalOptions?.withDeleted || false,
});
}
async findById(userId: string): Promise<User | null> {
return this.userRepository.findOne({
where: {
userId,
},
});
}
async create(user: Partial<User>): Promise<User> {
try {
const newUser = this.userRepository.create(user);
return await this.userRepository.save(newUser);
} catch (error) {
if (error instanceof QueryFailedError) {
throw new ConflictException(this.getDuplicateErrorMessage(error));
}
throw new BadRequestException('创建用户失败');
}
}
async update(userId: string, user: Partial<User>): Promise<User> {
const existingUser = await this.userRepository.findOne({
where: { userId },
});
if (!existingUser) {
throw new BadRequestException('User not found');
}
try {
Object.assign(existingUser, user);
return await this.userRepository.save(existingUser);
} catch (error) {
if (error instanceof QueryFailedError) {
throw new ConflictException(this.getDuplicateErrorMessage(error));
}
}
}
async delete(userId: string, soft: boolean) {
const existingUser = await this.userRepository.findOne({
where: { userId },
withDeleted: true,
});
if (!existingUser) {
throw new BadRequestException('用户不存在');
}
if (existingUser.deletedAt && soft) {
throw new BadRequestException('账户已注销,不得重复操作');
}
if (!existingUser.deletedAt && !soft) {
throw new BadRequestException('账号未注销,请先注销再执行删除操作');
}
return soft
? await this.userRepository.softDelete(existingUser.userId)
: await this.userRepository.delete(existingUser.userId);
}
hashPassword(password: string, salt: string): string {
return createHash('sha256').update(`${password}${salt}`).digest('hex');
}
generateSalt(): string {
return uuid().replace(/-/g, '');
}
async setPassword(userId: string, password: string): Promise<User> {
const user = await this.userRepository.findOne({ where: { userId } });
if (!user) {
throw new BadRequestException('User not found');
}
const salt = this.generateSalt();
user.password_hash = this.hashPassword(password, salt);
user.salt = salt;
return this.userRepository.save(user);
}
private getDuplicateErrorMessage(error: QueryFailedError): string {
// 根据具体的错误信息返回友好的提示
if (error.message.includes('IDX_user_username')) {
return '账户名已被使用';
}
if (error.message.includes('IDX_user_email')) {
return '邮箱已被使用';
}
if (error.message.includes('IDX_user_phone')) {
return '手机号已被使用';
}
return '该登陆方式异常,请更换其他登陆方式或联系管理员';
}
async list(page = 1, pageSize = 20) {
const queryBuilder = this.userRepository.createQueryBuilder('user');
queryBuilder.withDeleted();
queryBuilder.orderBy('user.createdAt', 'DESC');
queryBuilder.skip((page - 1) * pageSize);
queryBuilder.take(pageSize);
const [items, total] = await queryBuilder.getManyAndCount();
return {
items,
total,
page,
pageSize,
};
}
}

View File

@@ -0,0 +1,19 @@
import { IsEnum, IsString, Length, ValidateIf } from 'class-validator';
export class SendVerificationCodeDto {
@IsEnum(['phone', 'email'], { message: '请求类型错误' })
targetType: 'phone' | 'email';
@IsEnum(['login'], { message: '请求类型错误' })
type: 'login';
@ValidateIf((o) => o.targetType === 'phone')
@IsString({ message: '手机号必须输入' })
@Length(11, 11, { message: '手机号异常' }) // 中国大陆11位数字
phone?: string;
@ValidateIf((o) => o.targetType === 'email')
@IsString({ message: '邮箱必须输入' })
@Length(6, 254, { message: '邮箱异常' }) // RFC 5321
email?: string;
}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { VerificationController } from './verification.controller';
describe('VerificationController', () => {
let controller: VerificationController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [VerificationController],
}).compile();
controller = module.get<VerificationController>(VerificationController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -0,0 +1,34 @@
import {
BadRequestException,
Body,
Controller,
Post,
UseGuards,
} from '@nestjs/common';
import { SendVerificationCodeDto } from './dto/send-verification-code.dto';
import { VerificationService } from './verification.service';
import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
@Controller('verification')
export class VerificationController {
constructor(private readonly verificationService: VerificationService) {}
@Post('send')
@UseGuards(ThrottlerGuard)
@Throttle({ default: { limit: 20, ttl: 60000 } })
async sendVerificationCode(@Body() dto: SendVerificationCodeDto) {
switch (dto.type) {
case 'login':
switch (dto.targetType) {
case 'phone':
return this.verificationService.sendPhoneCode(dto.phone, dto.type);
case 'email':
return this.verificationService.sendEmailCode(dto.email, dto.type);
default:
throw new BadRequestException('不支持的目标类型');
}
default:
throw new BadRequestException('不支持的验证码类型');
}
}
}

View File

@@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';
import { VerificationController } from './verification.controller';
import { VerificationService } from './verification.service';
import { NotificationModule } from 'src/notification/notification.module';
@Module({
controllers: [VerificationController],
providers: [VerificationService],
exports: [VerificationService],
imports: [NotificationModule],
})
export class VerificationModule {}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { VerificationService } from './verification.service';
describe('VerificationService', () => {
let service: VerificationService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [VerificationService],
}).compile();
service = module.get<VerificationService>(VerificationService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -0,0 +1,127 @@
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
import { NotificationService } from 'src/notification/notification.service';
@Injectable()
export class VerificationService {
private readonly logger = new Logger(VerificationService.name);
constructor(private readonly notificationService: NotificationService) {}
private pool: Map<
string,
{
code: string;
createdAt: number;
expiredAt: number;
tryCount: number;
maxTryCount: number;
}
> = new Map();
/**
* @deprecated 该方法暂时弃用,因为没有申请到签名
*/
async sendPhoneCode(phone: string, type: 'login') {
const key = `phone:${phone}:${type}`;
// 检测是否在冷却时间内
// TODO
// 生成验证码
const code = this.generateCode();
this.logger.log(`Phone[${phone}] code: ${code}`);
// 发送验证码
// await this.notificationService.sendSMS(phone, type, code);
// 存储验证码
this.saveCode(key, code);
throw new Error('不允许的登陆方式');
return true;
}
async sendEmailCode(email: string, type: 'login') {
const key = `email:${email}:${type}`;
// 检测是否在冷却时间内
if (this.isInCooldownPeriod(key)) {
throw new BadRequestException('发送过于频繁,请稍后再试');
}
// 生成验证码
const code = this.generateCode();
// 存储验证码
this.saveCode(key, code);
this.logger.log(`Email[${email}] code: ${code}`);
// 发送验证码
await this.notificationService
.sendMail({ type: 'login-verify', targetMail: email, code })
.catch(() => {
this.clearCode(key);
throw new BadRequestException('发送失败,请稍后再试');
});
return true;
}
private isInCooldownPeriod(key: string) {
const item = this.pool.get(key);
if (!item) {
return false;
}
// 冷却60秒
if (Date.now() - item.createdAt > 60 * 1000) {
return false;
}
return true;
}
private saveCode(key: string, code: string) {
this.pool.set(key, {
code: code,
createdAt: Date.now(),
expiredAt: Date.now() + 10 * 60 * 1000, // 10分钟过期
tryCount: 0,
maxTryCount: 5,
});
}
private clearCode(key: string) {
this.pool.delete(key);
}
verifyPhoneCode(phone: string, code: string, type: 'login') {
const key = `phone:${phone}:${type}`;
return this.verifyCode(key, code);
}
verifyEmailCode(email: string, code: string, type: 'login') {
const key = `email:${email}:${type}`;
return this.verifyCode(key, code);
}
/**
* @returns 0: 验证码正确, -1: 验证码不存在或已过期, -2: 验证码错误, -3: 超过最大尝试次数
*/
private verifyCode(key: string, code: string) {
const data = this.pool.get(key);
if (!data) {
return -1;
}
if (data.tryCount >= data.maxTryCount) {
return -3;
}
if (data.expiredAt < Date.now()) {
return -1;
}
if (data.code !== code) {
data.tryCount++;
return -2;
}
this.pool.delete(key);
return 0;
}
private generateCode() {
return Math.floor(100000 + Math.random() * 900000).toString();
}
}

View File

@@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});

View File

@@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

View File

@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

View File

@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
}
}

41
tone-page-web/.gitignore vendored Normal file
View File

@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

36
tone-page-web/README.md Normal file
View File

@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

View File

@@ -0,0 +1,80 @@
'use client';
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { BlogApi } from "@/lib/api";
import { BlogComment } from "@/lib/types/blogComment";
import { Send, Undo2 } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { toast } from "sonner";
interface BlogCommentToolProps {
blogId: string;
onInsertComment: (b: BlogComment) => void;
replayTarget: BlogComment | null;
handleClearReplayTarget: () => void;
}
export function BlogCommentTool({ blogId, onInsertComment, replayTarget, handleClearReplayTarget }: BlogCommentToolProps) {
const [comment, setComment] = useState('');
const textareaRef = useRef<HTMLTextAreaElement>(null);
useEffect(() => {
if (replayTarget && textareaRef.current) {
textareaRef.current.focus();
textareaRef.current.scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'start'
})
}
}, [replayTarget]);
const submit = async () => {
if (comment.trim().length === 0) return;
try {
const res = await BlogApi.createComment(blogId, comment, replayTarget ? replayTarget.id : undefined);
if (res) {
toast.success('发布成功');
setComment('');
onInsertComment(res);
handleClearReplayTarget();
}
} catch (error) {
if ((error as { statusCode: number }).statusCode === 429) {
return toast.error('操作太频繁了,稍后再试吧')
}
toast.error('发布失败')
}
}
const getPlaceHolderText = () => {
if (!replayTarget) return '评论';
let replayComment = replayTarget.content.trim();
if (replayComment.length > 8) {
replayComment = replayComment.slice(0, 8) + '...';
}
const replayUser = replayTarget.user ? replayTarget.user.nickname : '匿名';
return `回复 ${replayUser}${replayComment}`;
}
return (
<div className="my-3 flex items-end gap-2">
<Textarea
ref={textareaRef}
placeholder={getPlaceHolderText()}
onChange={v => setComment(v.target.value)}
value={comment} />
<Button variant='outline' size='icon' onClick={() => submit()} disabled={comment.trim().length === 0}>
<Send />
</Button>
{replayTarget && <Button variant='outline' size='icon' onClick={() => handleClearReplayTarget()}>
<Undo2 />
</Button>}
</div>
)
}

View File

@@ -0,0 +1,81 @@
import useSWR from "swr";
import { BlogCommentTool } from "./BlogCommentTool";
import { BlogApi } from "@/lib/api";
import { BlogComment } from "@/lib/types/blogComment";
import { useState } from "react";
import { useUserMe } from "@/hooks/user/use-user-me";
export function BlogComments({ blogId }: { blogId: string }) {
const { data, mutate } = useSWR(
`/api/blog/${blogId}/comments`,
() => BlogApi.getComments(blogId),
)
const { user } = useUserMe();
const insertComment = async (newOne: BlogComment) => {
await mutate(
(comments) => {
if (!comments) return [newOne];
return [newOne, ...comments]
},
{ revalidate: false }
)
}
const [replayTarget, setReplayTarget] = useState<BlogComment | null>(null);
return (
data && <div className="" >
<h1 className="px-2 border-l-4 border-zinc-300"> {data.length}</h1>
<BlogCommentTool
blogId={blogId}
onInsertComment={insertComment}
replayTarget={replayTarget}
handleClearReplayTarget={() => setReplayTarget(null)}
/>
<div className="text-sm text-zinc-600">
{
user ? (<span>{user.nickname}</span>) : (<span></span>)
}
</div>
<div className="flex flex-col">
{
data.filter(d => !d.parentId)
.map((d) => (
<div key={d.id} className="border-b border-zinc-300 py-2 last:border-none">
<h1 className="text-zinc-500">{d.user ? d.user.nickname : '匿名'}</h1>
<div className="whitespace-pre-wrap break-all">{d.content}</div>
<div className="text-xs text-zinc-500 flex gap-2">
<p>{new Date(d.createdAt).toLocaleString()}</p>
<p>{d.address}</p>
<p className="text-zinc-900 cursor-pointer" onClick={() => setReplayTarget(d)}></p>
</div>
{
data.filter(c => c.parentId === d.id).length > 0 && (
<div className="flex flex-col ml-5 my-1">
{
data.filter(c => c.parentId === d.id).map(c => (
<div key={c.id} className="border-b border-zinc-300 py-1 last:border-none">
<h1 className="text-zinc-500">{c.user ? c.user.nickname : '匿名'}</h1>
<div className="whitespace-pre-wrap break-all">{c.content}</div>
<div className="text-xs text-zinc-500 flex gap-2">
<p>{new Date().toLocaleString()}</p>
<p>{c.address}</p>
</div>
</div>
))
}
</div>
)
}
</div>
))
}
</div >
</div>
)
}

Some files were not shown because too many files have changed in this diff Show More