@svton/cli 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/index.js +20 -7
  2. package/dist/index.mjs +20 -7
  3. package/features.json +339 -0
  4. package/package.json +4 -1
  5. package/templates/apps/admin/next-env.d.ts +2 -0
  6. package/templates/apps/admin/next.config.js +15 -0
  7. package/templates/apps/admin/package.json.tpl +54 -0
  8. package/templates/apps/admin/postcss.config.js +6 -0
  9. package/templates/apps/admin/src/app/globals.css +37 -0
  10. package/templates/apps/admin/src/app/layout.tsx +19 -0
  11. package/templates/apps/admin/src/app/login/page.tsx +96 -0
  12. package/templates/apps/admin/src/app/page.tsx +8 -0
  13. package/templates/apps/admin/src/app/users/page.tsx +165 -0
  14. package/templates/apps/admin/src/components/ui/switch.tsx +29 -0
  15. package/templates/apps/admin/src/hooks/useAPI.ts +130 -0
  16. package/templates/apps/admin/src/lib/api-client.ts +112 -0
  17. package/templates/apps/admin/src/lib/api-server.ts +95 -0
  18. package/templates/apps/admin/tailwind.config.js +54 -0
  19. package/templates/apps/admin/tsconfig.json +22 -0
  20. package/templates/apps/backend/.env.example +29 -0
  21. package/templates/apps/backend/nest-cli.json +8 -0
  22. package/templates/apps/backend/package.json.tpl +57 -0
  23. package/templates/apps/backend/prisma/schema.prisma +72 -0
  24. package/templates/apps/backend/prisma/seed.ts +32 -0
  25. package/templates/apps/backend/src/app.controller.ts +15 -0
  26. package/templates/apps/backend/src/app.module.ts +85 -0
  27. package/templates/apps/backend/src/app.service.ts +12 -0
  28. package/templates/apps/backend/src/auth/auth.controller.ts +31 -0
  29. package/templates/apps/backend/src/auth/auth.module.ts +27 -0
  30. package/templates/apps/backend/src/auth/auth.service.ts +89 -0
  31. package/templates/apps/backend/src/auth/jwt-auth.guard.ts +5 -0
  32. package/templates/apps/backend/src/auth/jwt.strategy.ts +27 -0
  33. package/templates/apps/backend/src/config/env.schema.ts +35 -0
  34. package/templates/apps/backend/src/main.ts +51 -0
  35. package/templates/apps/backend/src/object-storage/object-storage.controller.ts +114 -0
  36. package/templates/apps/backend/src/object-storage/object-storage.module.ts +7 -0
  37. package/templates/apps/backend/src/prisma/prisma.module.ts +9 -0
  38. package/templates/apps/backend/src/prisma/prisma.service.ts +13 -0
  39. package/templates/apps/backend/src/user/user.controller.ts +50 -0
  40. package/templates/apps/backend/src/user/user.module.ts +12 -0
  41. package/templates/apps/backend/src/user/user.service.ts +117 -0
  42. package/templates/apps/backend/tsconfig.json +23 -0
  43. package/templates/apps/mobile/babel.config.js +8 -0
  44. package/templates/apps/mobile/config/index.ts +65 -0
  45. package/templates/apps/mobile/package.json.tpl +48 -0
  46. package/templates/apps/mobile/project.config.json.tpl +17 -0
  47. package/templates/apps/mobile/src/app.config.ts +9 -0
  48. package/templates/apps/mobile/src/app.scss +4 -0
  49. package/templates/apps/mobile/src/app.ts +8 -0
  50. package/templates/apps/mobile/src/hooks/useAPI.ts +285 -0
  51. package/templates/apps/mobile/src/pages/index/index.scss +7 -0
  52. package/templates/apps/mobile/src/pages/index/index.tsx +49 -0
  53. package/templates/apps/mobile/src/services/api.ts +155 -0
  54. package/templates/apps/mobile/src/services/upload.service.ts +41 -0
  55. package/templates/apps/mobile/tsconfig.json +21 -0
  56. package/templates/configs/authz.config.ts +10 -0
  57. package/templates/configs/cache.config.ts +14 -0
  58. package/templates/configs/oauth.config.ts +20 -0
  59. package/templates/configs/payment.config.ts +44 -0
  60. package/templates/configs/queue.config.ts +21 -0
  61. package/templates/configs/rate-limit.config.ts +16 -0
  62. package/templates/configs/sms.config.ts +11 -0
  63. package/templates/configs/storage.config.ts +14 -0
  64. package/templates/examples/README.md +258 -0
  65. package/templates/examples/authz/README.md +273 -0
  66. package/templates/examples/authz/roles.guard.ts +37 -0
  67. package/templates/examples/authz/user.controller.ts +116 -0
  68. package/templates/examples/cache/README.md +82 -0
  69. package/templates/examples/cache/user.controller.ts +42 -0
  70. package/templates/examples/cache/user.service.ts +78 -0
  71. package/templates/examples/oauth/README.md +192 -0
  72. package/templates/examples/oauth/auth.controller.ts +99 -0
  73. package/templates/examples/oauth/auth.service.ts +97 -0
  74. package/templates/examples/payment/README.md +151 -0
  75. package/templates/examples/payment/order.controller.ts +56 -0
  76. package/templates/examples/payment/order.service.ts +132 -0
  77. package/templates/examples/payment/webhook.controller.ts +73 -0
  78. package/templates/examples/queue/README.md +134 -0
  79. package/templates/examples/queue/email.controller.ts +34 -0
  80. package/templates/examples/queue/email.processor.ts +68 -0
  81. package/templates/examples/queue/email.service.ts +64 -0
  82. package/templates/examples/rate-limit/README.md +249 -0
  83. package/templates/examples/rate-limit/api.controller.ts +113 -0
  84. package/templates/examples/sms/README.md +121 -0
  85. package/templates/examples/sms/sms.service.ts +69 -0
  86. package/templates/examples/sms/verification.controller.ts +100 -0
  87. package/templates/examples/storage/README.md +224 -0
  88. package/templates/examples/storage/upload.controller.ts +117 -0
  89. package/templates/examples/storage/upload.service.ts +123 -0
  90. package/templates/packages/types/package.json.tpl +16 -0
  91. package/templates/packages/types/src/api.ts +88 -0
  92. package/templates/packages/types/src/common.ts +89 -0
  93. package/templates/packages/types/src/index.ts +3 -0
  94. package/templates/packages/types/tsconfig.json +16 -0
  95. package/templates/skills/authz.skill.md +42 -0
  96. package/templates/skills/base.skill.md +57 -0
  97. package/templates/skills/cache.skill.md +88 -0
  98. package/templates/skills/oauth.skill.md +41 -0
  99. package/templates/skills/payment.skill.md +129 -0
  100. package/templates/skills/queue.skill.md +140 -0
  101. package/templates/skills/rate-limit.skill.md +38 -0
  102. package/templates/skills/sms.skill.md +39 -0
  103. package/templates/skills/storage.skill.md +42 -0
@@ -0,0 +1,42 @@
1
+ # 权限控制使用指南
2
+
3
+ 本项目已集成 `@svton/nestjs-authz` 权限控制模块,实现 RBAC 权限管理。
4
+
5
+ ## 已安装的包
6
+
7
+ - `@svton/nestjs-authz` - 权限控制模块
8
+
9
+ ## 配置文件
10
+
11
+ - `src/config/authz.config.ts` - 权限配置
12
+
13
+ ## 示例代码位置
14
+
15
+ 查看 `src/examples/authz/` 目录获取完整示例。
16
+
17
+ ## 核心装饰器
18
+
19
+ ### @Roles - 角色权限
20
+
21
+ ```typescript
22
+ @Roles('admin')
23
+ @Get('admin')
24
+ async adminOnly() {
25
+ return { message: 'Admin only' };
26
+ }
27
+ ```
28
+
29
+ ### @Permissions - 细粒度权限
30
+
31
+ ```typescript
32
+ @Permissions('user:delete')
33
+ @Delete(':id')
34
+ async delete(@Param('id') id: string) {
35
+ // 删除用户
36
+ }
37
+ ```
38
+
39
+ ## 文档链接
40
+
41
+ - 官方文档:https://751848178.github.io/svton/packages/nestjs-authz
42
+ - 示例代码:`src/examples/authz/`
@@ -0,0 +1,57 @@
1
+ # 项目能力索引
2
+
3
+ 本项目基于 Svton 全栈框架创建,这是一个企业级 Monorepo 架构。
4
+
5
+ ## 项目结构
6
+
7
+ ```
8
+ src/
9
+ ├── config/ # 配置文件
10
+ ├── examples/ # 功能示例代码
11
+ ├── modules/ # 业务模块
12
+ └── main.ts # 应用入口
13
+ ```
14
+
15
+ ## 核心能力
16
+
17
+ 本项目已集成以下功能模块,每个模块都有对应的 skill 文档和示例代码。
18
+
19
+ ### 查看功能文档
20
+
21
+ - 查看 `.kiro/skills/` 目录下的各个功能 skill 文档
22
+ - 查看 `src/examples/` 目录下的示例代码
23
+ - 查看 `src/config/` 目录下的配置文件
24
+
25
+ ## 开发建议
26
+
27
+ 当你需要使用某个功能时:
28
+
29
+ 1. 查看对应的 skill 文档了解 API 和最佳实践
30
+ 2. 参考 `src/examples/` 目录下的示例代码
31
+ 3. 根据需要修改 `src/config/` 中的配置
32
+ 4. 查看官方文档获取更多信息
33
+
34
+ ## 环境配置
35
+
36
+ 项目使用 `.env` 文件管理环境变量,请参考 `.env.example` 文件配置必要的环境变量。
37
+
38
+ ## 文档资源
39
+
40
+ - Svton 官方文档:https://751848178.github.io/svton
41
+ - GitHub:https://github.com/751848178/svton
42
+
43
+ ## 常用命令
44
+
45
+ ```bash
46
+ # 开发模式
47
+ pnpm dev
48
+
49
+ # 构建
50
+ pnpm build
51
+
52
+ # 启动生产环境
53
+ pnpm start
54
+
55
+ # 运行测试
56
+ pnpm test
57
+ ```
@@ -0,0 +1,88 @@
1
+ # 缓存功能使用指南
2
+
3
+ 本项目已集成 `@svton/nestjs-cache` 缓存模块,提供声明式缓存能力。
4
+
5
+ ## 已安装的包
6
+
7
+ - `@svton/nestjs-cache` - 缓存装饰器模块
8
+ - `@svton/nestjs-redis` - Redis 连接模块
9
+
10
+ ## 配置文件
11
+
12
+ - `src/config/cache.config.ts` - 缓存配置
13
+ - `.env` - 环境变量配置(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD)
14
+
15
+ ## 示例代码位置
16
+
17
+ 查看 `src/examples/cache/` 目录获取完整示例:
18
+ - `user.service.ts` - Service 层缓存使用
19
+ - `user.controller.ts` - Controller 层使用
20
+ - `README.md` - 详细说明文档
21
+
22
+ ## 核心装饰器
23
+
24
+ ### @Cacheable - 缓存查询结果
25
+
26
+ ```typescript
27
+ @Cacheable({ key: 'user:#id', ttl: 3600 })
28
+ async findOne(id: number) {
29
+ return this.prisma.user.findUnique({ where: { id } });
30
+ }
31
+ ```
32
+
33
+ ### @CacheEvict - 清除缓存
34
+
35
+ ```typescript
36
+ @CacheEvict({ key: 'user:#id' })
37
+ async update(id: number, data: UpdateUserDto) {
38
+ return this.prisma.user.update({ where: { id }, data });
39
+ }
40
+ ```
41
+
42
+ ### @CachePut - 更新缓存
43
+
44
+ ```typescript
45
+ @CachePut({ key: 'user:#id' })
46
+ async updateAndRefresh(id: number, data: UpdateUserDto) {
47
+ return this.prisma.user.update({ where: { id }, data });
48
+ }
49
+ ```
50
+
51
+ ## Key 表达式规则
52
+
53
+ - `#id` - 从 request.params 获取
54
+ - `#0`, `#1` - 位置参数
55
+ - `#paramName` - 参数名
56
+ - `#body.field` - 从 request.body 获取
57
+
58
+ ## 最佳实践
59
+
60
+ 1. **合理设置 TTL**:根据数据更新频率设置过期时间
61
+ 2. **及时清除缓存**:更新/删除操作使用 @CacheEvict
62
+ 3. **避免缓存穿透**:对空结果也进行缓存
63
+ 4. **使用命名空间**:key 前缀区分不同业务
64
+
65
+ ## 常见场景
66
+
67
+ ### 用户信息缓存
68
+ ```typescript
69
+ @Cacheable({ key: 'user:#id', ttl: 3600 })
70
+ async getUserById(id: number) { }
71
+ ```
72
+
73
+ ### 列表查询缓存
74
+ ```typescript
75
+ @Cacheable({ key: 'users:list:#page:#pageSize', ttl: 300 })
76
+ async getUsers(page: number, pageSize: number) { }
77
+ ```
78
+
79
+ ### 批量清除缓存
80
+ ```typescript
81
+ @CacheEvict({ key: 'users:*', pattern: true })
82
+ async clearAllUserCache() { }
83
+ ```
84
+
85
+ ## 文档链接
86
+
87
+ - 官方文档:https://751848178.github.io/svton/packages/nestjs-cache
88
+ - 示例代码:`src/examples/cache/`
@@ -0,0 +1,41 @@
1
+ # OAuth 登录使用指南
2
+
3
+ 本项目已集成 `@svton/nestjs-oauth` OAuth 登录模块,支持微信登录。
4
+
5
+ ## 已安装的包
6
+
7
+ - `@svton/nestjs-oauth` - OAuth 登录模块
8
+
9
+ ## 配置文件
10
+
11
+ - `src/config/oauth.config.ts` - OAuth 配置
12
+ - `.env` - 环境变量配置
13
+
14
+ ## 示例代码位置
15
+
16
+ 查看 `src/examples/oauth/` 目录获取完整示例。
17
+
18
+ ## 支持的登录方式
19
+
20
+ - 微信开放平台(PC 扫码登录)
21
+ - 微信公众号(网页授权)
22
+ - 微信小程序(code2Session)
23
+
24
+ ## 核心 API
25
+
26
+ ### 获取授权 URL
27
+
28
+ ```typescript
29
+ const url = this.oauthService.wechat.getAuthorizationUrl('open', state);
30
+ ```
31
+
32
+ ### 小程序登录
33
+
34
+ ```typescript
35
+ const result = await this.oauthService.wechat.code2Session(code);
36
+ ```
37
+
38
+ ## 文档链接
39
+
40
+ - 官方文档:https://751848178.github.io/svton/packages/nestjs-oauth
41
+ - 示例代码:`src/examples/oauth/`
@@ -0,0 +1,129 @@
1
+ # 支付功能使用指南
2
+
3
+ 本项目已集成 `@svton/nestjs-payment` 支付模块,支持微信支付和支付宝。
4
+
5
+ ## 已安装的包
6
+
7
+ - `@svton/nestjs-payment` - 支付模块(微信支付 V3 + 支付宝)
8
+
9
+ ## 配置文件
10
+
11
+ - `src/config/payment.config.ts` - 支付配置
12
+ - `.env` - 环境变量配置(商户信息、密钥等)
13
+
14
+ ## 示例代码位置
15
+
16
+ 查看 `src/examples/payment/` 目录获取完整示例:
17
+ - `order.service.ts` - 订单创建服务
18
+ - `order.controller.ts` - 支付接口
19
+ - `webhook.controller.ts` - 支付回调处理
20
+ - `README.md` - 详细说明文档
21
+
22
+ ## 支持的支付方式
23
+
24
+ ### 微信支付
25
+ - JSAPI 支付(公众号/小程序)
26
+ - Native 支付(扫码支付)
27
+ - APP 支付
28
+ - H5 支付
29
+ - 小程序支付
30
+
31
+ ### 支付宝
32
+ - 电脑网站支付(PC)
33
+ - 手机网站支付(H5)
34
+ - APP 支付
35
+
36
+ ## 核心 API
37
+
38
+ ### 创建微信订单
39
+
40
+ ```typescript
41
+ const result = await this.paymentService.wechat.createOrder({
42
+ outTradeNo: orderId,
43
+ totalAmount: amount,
44
+ description: '商品购买',
45
+ userId: openid,
46
+ }, 'jsapi');
47
+ ```
48
+
49
+ ### 创建支付宝订单
50
+
51
+ ```typescript
52
+ const result = await this.paymentService.alipay.createOrder({
53
+ outTradeNo: orderId,
54
+ totalAmount: amount,
55
+ description: '商品购买',
56
+ }, 'page');
57
+ ```
58
+
59
+ ### 查询订单状态
60
+
61
+ ```typescript
62
+ const status = await this.paymentService.wechat.queryOrder(outTradeNo);
63
+ ```
64
+
65
+ ### 申请退款
66
+
67
+ ```typescript
68
+ const refund = await this.paymentService.wechat.refund({
69
+ outTradeNo: orderId,
70
+ outRefundNo: refundId,
71
+ refundAmount: amount,
72
+ totalAmount: totalAmount,
73
+ });
74
+ ```
75
+
76
+ ## 回调处理
77
+
78
+ ### 微信支付回调
79
+
80
+ ```typescript
81
+ @Post('webhook/wechat')
82
+ async wechatWebhook(@Req() req: Request) {
83
+ const result = await this.paymentService.wechat.handleNotify(req);
84
+ // 处理支付成功逻辑
85
+ return { code: 'SUCCESS', message: '成功' };
86
+ }
87
+ ```
88
+
89
+ ### 支付宝回调
90
+
91
+ ```typescript
92
+ @Post('webhook/alipay')
93
+ async alipayWebhook(@Body() body: any) {
94
+ const result = await this.paymentService.alipay.handleNotify(body);
95
+ // 处理支付成功逻辑
96
+ return 'success';
97
+ }
98
+ ```
99
+
100
+ ## 最佳实践
101
+
102
+ 1. **订单号唯一性**:确保 outTradeNo 全局唯一
103
+ 2. **金额单位**:统一使用分为单位
104
+ 3. **回调幂等性**:支付回调可能重复,需要幂等处理
105
+ 4. **异步通知**:优先使用异步通知,不依赖同步返回
106
+ 5. **安全验证**:验证回调签名,防止伪造
107
+
108
+ ## 环境变量配置
109
+
110
+ ```env
111
+ # 微信支付
112
+ WECHAT_MCH_ID=商户号
113
+ WECHAT_PRIVATE_KEY=./certs/apiclient_key.pem
114
+ WECHAT_SERIAL_NO=证书序列号
115
+ WECHAT_API_V3_KEY=APIv3密钥
116
+ WECHAT_APP_ID=关联的AppID
117
+
118
+ # 支付宝
119
+ ALIPAY_APP_ID=应用ID
120
+ ALIPAY_PRIVATE_KEY=./certs/alipay_private_key.pem
121
+ ALIPAY_PUBLIC_KEY=./certs/alipay_public_key.pem
122
+ ```
123
+
124
+ ## 文档链接
125
+
126
+ - 官方文档:https://751848178.github.io/svton/packages/nestjs-payment
127
+ - 示例代码:`src/examples/payment/`
128
+ - 微信支付文档:https://pay.weixin.qq.com/wiki/doc/apiv3/
129
+ - 支付宝文档:https://opendocs.alipay.com/
@@ -0,0 +1,140 @@
1
+ # 消息队列使用指南
2
+
3
+ 本项目已集成 `@svton/nestjs-queue` 消息队列模块,基于 BullMQ 实现。
4
+
5
+ ## 已安装的包
6
+
7
+ - `@svton/nestjs-queue` - 队列模块
8
+ - `@svton/nestjs-redis` - Redis 连接模块
9
+
10
+ ## 配置文件
11
+
12
+ - `src/config/queue.config.ts` - 队列配置
13
+ - `.env` - 环境变量配置(REDIS_HOST, REDIS_PORT)
14
+
15
+ ## 示例代码位置
16
+
17
+ 查看 `src/examples/queue/` 目录获取完整示例:
18
+ - `email.processor.ts` - 邮件队列处理器
19
+ - `email.service.ts` - 邮件发送服务
20
+ - `email.controller.ts` - API 接口
21
+ - `README.md` - 详细说明文档
22
+
23
+ ## 核心概念
24
+
25
+ - **Queue(队列)**:任务的容器
26
+ - **Job(任务)**:具体的执行单元
27
+ - **Processor(处理器)**:任务的执行逻辑
28
+ - **Worker(工作进程)**:执行任务的进程
29
+
30
+ ## 添加任务
31
+
32
+ ```typescript
33
+ await this.queueService.addJob('email', 'send', {
34
+ to: 'user@example.com',
35
+ subject: 'Welcome',
36
+ body: 'Welcome to our platform!',
37
+ });
38
+ ```
39
+
40
+ ## 定义处理器
41
+
42
+ ```typescript
43
+ @Processor({ name: 'email' })
44
+ @Injectable()
45
+ export class EmailProcessor {
46
+ @Process('send')
47
+ async handleSend(job: Job<EmailData>) {
48
+ const { to, subject, body } = job.data;
49
+ await this.sendEmail(to, subject, body);
50
+ }
51
+ }
52
+ ```
53
+
54
+ ## 任务选项
55
+
56
+ ### 延迟执行
57
+
58
+ ```typescript
59
+ await this.queueService.addJob('email', 'send', data, {
60
+ delay: 60000, // 延迟 60 秒
61
+ });
62
+ ```
63
+
64
+ ### 重试策略
65
+
66
+ ```typescript
67
+ await this.queueService.addJob('email', 'send', data, {
68
+ attempts: 3,
69
+ backoff: {
70
+ type: 'exponential',
71
+ delay: 1000,
72
+ },
73
+ });
74
+ ```
75
+
76
+ ### 定时任务
77
+
78
+ ```typescript
79
+ await this.queueService.addJob('report', 'daily', data, {
80
+ repeat: {
81
+ cron: '0 0 * * *', // 每天 0 点执行
82
+ },
83
+ });
84
+ ```
85
+
86
+ ## 任务优先级
87
+
88
+ ```typescript
89
+ await this.queueService.addJob('email', 'send', data, {
90
+ priority: 1, // 数字越小优先级越高
91
+ });
92
+ ```
93
+
94
+ ## 监听任务事件
95
+
96
+ ```typescript
97
+ @OnQueueCompleted({ name: 'email' })
98
+ async onCompleted(job: Job) {
99
+ console.log(`Job ${job.id} completed`);
100
+ }
101
+
102
+ @OnQueueFailed({ name: 'email' })
103
+ async onFailed(job: Job, error: Error) {
104
+ console.error(`Job ${job.id} failed:`, error);
105
+ }
106
+ ```
107
+
108
+ ## 常见场景
109
+
110
+ ### 发送邮件
111
+ ```typescript
112
+ await this.queueService.addJob('email', 'send', emailData);
113
+ ```
114
+
115
+ ### 生成报表
116
+ ```typescript
117
+ await this.queueService.addJob('report', 'generate', reportData);
118
+ ```
119
+
120
+ ### 数据同步
121
+ ```typescript
122
+ await this.queueService.addJob('sync', 'user', userData, {
123
+ attempts: 5,
124
+ backoff: { type: 'exponential', delay: 2000 },
125
+ });
126
+ ```
127
+
128
+ ## 最佳实践
129
+
130
+ 1. **任务幂等性**:确保任务可以安全重试
131
+ 2. **合理设置重试**:根据业务场景设置重试次数和策略
132
+ 3. **任务拆分**:大任务拆分成小任务,提高并发度
133
+ 4. **监控告警**:监听失败事件,及时处理异常
134
+ 5. **资源限制**:控制并发数,避免资源耗尽
135
+
136
+ ## 文档链接
137
+
138
+ - 官方文档:https://751848178.github.io/svton/packages/nestjs-queue
139
+ - 示例代码:`src/examples/queue/`
140
+ - BullMQ 文档:https://docs.bullmq.io/
@@ -0,0 +1,38 @@
1
+ # 限流功能使用指南
2
+
3
+ 本项目已集成 `@svton/nestjs-rate-limit` 限流模块,基于 Redis 实现。
4
+
5
+ ## 已安装的包
6
+
7
+ - `@svton/nestjs-rate-limit` - 限流模块
8
+ - `@svton/nestjs-redis` - Redis 连接模块
9
+
10
+ ## 配置文件
11
+
12
+ - `src/config/rate-limit.config.ts` - 限流配置
13
+ - `.env` - 环境变量配置
14
+
15
+ ## 示例代码位置
16
+
17
+ 查看 `src/examples/rate-limit/` 目录获取完整示例。
18
+
19
+ ## 核心装饰器
20
+
21
+ ### @RateLimit - 接口限流
22
+
23
+ ```typescript
24
+ @RateLimit({ ttl: 60, limit: 10 })
25
+ @Get('api')
26
+ async api() {
27
+ return { message: 'Success' };
28
+ }
29
+ ```
30
+
31
+ ### 全局限流
32
+
33
+ 在 `app.module.ts` 中配置全局限流规则。
34
+
35
+ ## 文档链接
36
+
37
+ - 官方文档:https://751848178.github.io/svton/packages/nestjs-rate-limit
38
+ - 示例代码:`src/examples/rate-limit/`
@@ -0,0 +1,39 @@
1
+ # 短信功能使用指南
2
+
3
+ 本项目已集成 `@svton/nestjs-sms` 短信模块,支持阿里云和腾讯云。
4
+
5
+ ## 已安装的包
6
+
7
+ - `@svton/nestjs-sms` - 短信发送模块
8
+
9
+ ## 配置文件
10
+
11
+ - `src/config/sms.config.ts` - 短信配置
12
+ - `.env` - 环境变量配置
13
+
14
+ ## 示例代码位置
15
+
16
+ 查看 `src/examples/sms/` 目录获取完整示例。
17
+
18
+ ## 核心 API
19
+
20
+ ### 发送短信
21
+
22
+ ```typescript
23
+ await this.smsService.send({
24
+ phoneNumber: '13800138000',
25
+ templateCode: 'SMS_123456',
26
+ templateParams: { code: '123456' },
27
+ });
28
+ ```
29
+
30
+ ### 发送验证码
31
+
32
+ ```typescript
33
+ await this.smsService.sendVerificationCode('13800138000', '123456');
34
+ ```
35
+
36
+ ## 文档链接
37
+
38
+ - 官方文档:https://751848178.github.io/svton/packages/nestjs-sms
39
+ - 示例代码:`src/examples/sms/`
@@ -0,0 +1,42 @@
1
+ # 对象存储使用指南
2
+
3
+ 本项目已集成 `@svton/nestjs-object-storage` 对象存储模块,支持七牛云和阿里云 OSS。
4
+
5
+ ## 已安装的包
6
+
7
+ - `@svton/nestjs-object-storage` - 对象存储抽象层
8
+ - `@svton/nestjs-object-storage-qiniu-kodo` - 七牛云实现
9
+
10
+ ## 配置文件
11
+
12
+ - `src/config/storage.config.ts` - 存储配置
13
+ - `.env` - 环境变量配置
14
+
15
+ ## 示例代码位置
16
+
17
+ 查看 `src/examples/storage/` 目录获取完整示例。
18
+
19
+ ## 核心 API
20
+
21
+ ### 上传文件
22
+
23
+ ```typescript
24
+ const result = await this.storageService.upload(file, 'uploads/');
25
+ ```
26
+
27
+ ### 获取上传凭证
28
+
29
+ ```typescript
30
+ const token = await this.storageService.getUploadToken();
31
+ ```
32
+
33
+ ### 删除文件
34
+
35
+ ```typescript
36
+ await this.storageService.delete(key);
37
+ ```
38
+
39
+ ## 文档链接
40
+
41
+ - 官方文档:https://751848178.github.io/svton/packages/nestjs-object-storage
42
+ - 示例代码:`src/examples/storage/`