create-bubbles 0.1.24 → 0.1.26

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 (204) hide show
  1. package/dist/index.js +15 -0
  2. package/package.json +1 -2
  3. package/template-nextjs-vinext-eslint/Dockerfile +4 -4
  4. package/template-nextjs-vinext-eslint/README.md +6 -2
  5. package/template-nextjs-vinext-eslint/docker-compose.yaml +4 -4
  6. package/template-nextjs-vinext-eslint/eslint.config.js +2 -0
  7. package/template-nextjs-vinext-eslint/package.json +28 -26
  8. package/template-nextjs-vinext-eslint/pnpm-workspace.yaml +13 -1
  9. package/template-nextjs-vinext-eslint/src/utils/request/core/index.ts +63 -45
  10. package/template-nextjs-vinext-eslint/src/utils/request/core/utils.ts +12 -6
  11. package/template-nextjs-vinext-eslint/vite.config.ts +1 -1
  12. package/template-react-rsbuild-biome/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  13. package/template-react-rsbuild-biome/AGENTS.md +11 -0
  14. package/template-react-rsbuild-biome/index.html +2 -2
  15. package/template-react-rsbuild-biome/package.json +25 -24
  16. package/template-react-rsbuild-biome/pnpm-workspace.yaml +5 -0
  17. package/template-react-rsbuild-biome/rsbuild.config.ts +1 -1
  18. package/template-react-rsbuild-biome/src/assets/icon/logo.svg +1 -1
  19. package/template-react-rsbuild-biome/src/assets/svg/draft.svg +4 -0
  20. package/template-react-rsbuild-biome/src/components/Icon/svg-icon/README.md +37 -0
  21. package/template-react-rsbuild-biome/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  22. package/template-react-rsbuild-biome/src/env.d.ts +7 -0
  23. package/template-react-rsbuild-biome/src/utils/request/index.ts +3 -4
  24. package/template-react-rsbuild-biome/tsconfig.json +1 -2
  25. package/template-taro-react-oxc/.oxlintrc.json +0 -1
  26. package/template-taro-react-oxc/package.json +53 -52
  27. package/template-taro-react-oxc/pnpm-workspace.yaml +46 -0
  28. package/template-taro-vue-eslint/package.json +56 -56
  29. package/template-vp-monorepo-react-hono/apps/web/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  30. package/template-vp-monorepo-react-hono/apps/web/AGENTS.md +11 -0
  31. package/template-vp-monorepo-react-hono/apps/web/package.json +1 -0
  32. package/template-vp-monorepo-react-hono/apps/web/src/assets/svg/draft.svg +4 -0
  33. package/template-vp-monorepo-react-hono/apps/web/src/components/Icon/svg-icon/README.md +37 -0
  34. package/template-vp-monorepo-react-hono/apps/web/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  35. package/template-vp-monorepo-react-hono/apps/web/tsconfig.json +1 -1
  36. package/template-vp-monorepo-react-hono/apps/web/vite.config.ts +2 -0
  37. package/template-vp-monorepo-react-hono/pnpm-workspace.yaml +1 -0
  38. package/template-vp-monorepo-react-nestjs/.agents/rules//344/273/243/347/240/201/350/256/276/350/256/241.md +4 -0
  39. package/template-vp-monorepo-react-nestjs/.agents/rules//345/205/261/344/272/253/344/273/243/347/240/201.md +4 -0
  40. package/template-vp-monorepo-react-nestjs/.spaces/01./344/274/201/344/270/232/347/272/247/351/241/271/347/233/256/347/272/247//351/234/200/346/261/202/346/226/207/346/241/243.md +177 -0
  41. package/template-vp-monorepo-react-nestjs/.spaces/server/04.upload.md +4504 -0
  42. package/template-vp-monorepo-react-nestjs/.spaces/server/05./344/270/212/344/274/240/346/224/271/351/200/240/346/226/271/346/241/210/README.md +858 -0
  43. package/template-vp-monorepo-react-nestjs/.spaces/server/06./345/205/254/345/205/261/351/230/237/345/210/227/346/216/245/345/205/245/346/226/271/346/241/210/README.md +1890 -0
  44. package/template-vp-monorepo-react-nestjs/.spaces/server/06./345/205/254/345/205/261/351/230/237/345/210/227/346/216/245/345/205/245/346/226/271/346/241/210//344/270/212/344/274/240/346/270/205/347/220/206.md +1465 -0
  45. package/template-vp-monorepo-react-nestjs/AGENTS.md +8 -12
  46. package/template-vp-monorepo-react-nestjs/apps/server/.agents/rules/error-handling.md +84 -0
  47. package/template-vp-monorepo-react-nestjs/apps/server/.env.development +60 -0
  48. package/template-vp-monorepo-react-nestjs/apps/server/.env.production +16 -0
  49. package/template-vp-monorepo-react-nestjs/apps/server/AGENTS.md +9 -0
  50. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/0000_military_colonel_america.sql +11 -0
  51. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/0001_loud_siren.sql +27 -0
  52. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/meta/0000_snapshot.json +97 -0
  53. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/meta/0001_snapshot.json +354 -0
  54. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/meta/_journal.json +20 -0
  55. package/template-vp-monorepo-react-nestjs/apps/server/package.json +4 -0
  56. package/template-vp-monorepo-react-nestjs/apps/server/src/app.module.ts +14 -2
  57. package/template-vp-monorepo-react-nestjs/apps/server/src/common/adapters/fastify.adapter.ts +6 -0
  58. package/template-vp-monorepo-react-nestjs/apps/server/src/config/index.ts +2 -0
  59. package/template-vp-monorepo-react-nestjs/apps/server/src/config/queue.config.ts +105 -0
  60. package/template-vp-monorepo-react-nestjs/apps/server/src/config/storage.config.ts +33 -0
  61. package/template-vp-monorepo-react-nestjs/apps/server/src/database/schema.ts +57 -1
  62. package/template-vp-monorepo-react-nestjs/apps/server/src/main.ts +1 -0
  63. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/auth/auth.service.ts +1 -3
  64. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/auth/dto/auth-repsponse.dto.ts +2 -2
  65. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/queue-worker.bootstrap.ts +24 -0
  66. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.constants.ts +24 -0
  67. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.contracts.ts +35 -0
  68. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.module.ts +56 -0
  69. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.processor.ts +62 -0
  70. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.service.ts +58 -0
  71. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/error-catelog.spec.ts +34 -0
  72. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/dto/initiate-mutipart-upload.dto.ts +26 -0
  73. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/dto/upload-params.dto.ts +15 -0
  74. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/storage/exact-size.transform.ts +66 -0
  75. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/storage/minio-storage.adapter.ts +239 -0
  76. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/storage/storage.port.ts +61 -0
  77. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.constants.ts +23 -0
  78. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.controller.ts +109 -0
  79. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.errors.ts +80 -0
  80. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.module.ts +20 -0
  81. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.reponsitory.ts +166 -0
  82. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.service.ts +696 -0
  83. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/utils/object-key.ts +10 -0
  84. package/template-vp-monorepo-react-nestjs/apps/server/test/task-queue.integration.spec.ts +120 -0
  85. package/template-vp-monorepo-react-nestjs/apps/server/test/task-queue.processor.spec.ts +63 -0
  86. package/template-vp-monorepo-react-nestjs/apps/server/test/task-queue.service.spec.ts +106 -0
  87. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  88. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//345/274/271/347/252/227/347/273/204/344/273/266.md +4 -0
  89. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//346/226/207/344/273/266/346/213/206/345/210/206.md +4 -0
  90. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//347/273/204/344/273/266/345/221/275/345/220/215.md +3 -0
  91. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//350/241/250/346/240/274/351/241/265/351/235/242.md +11 -0
  92. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//351/241/265/351/235/242/346/216/245/345/217/243.md +3 -0
  93. package/template-vp-monorepo-react-nestjs/apps/web/.env.dev +1 -1
  94. package/template-vp-monorepo-react-nestjs/apps/web/AGENTS.md +16 -0
  95. package/template-vp-monorepo-react-nestjs/apps/web/README.MD +153 -0
  96. package/template-vp-monorepo-react-nestjs/apps/web/index.html +3 -2
  97. package/template-vp-monorepo-react-nestjs/apps/web/package.json +6 -1
  98. package/template-vp-monorepo-react-nestjs/apps/web/public/favicon.svg +9 -1
  99. package/template-vp-monorepo-react-nestjs/apps/web/src/App.module.css +5 -0
  100. package/template-vp-monorepo-react-nestjs/apps/web/src/App.tsx +16 -9
  101. package/template-vp-monorepo-react-nestjs/apps/web/src/api/auth.ts +9 -0
  102. package/template-vp-monorepo-react-nestjs/apps/web/src/assets/svg/draft.svg +4 -0
  103. package/template-vp-monorepo-react-nestjs/apps/web/src/components/DraftProTable/DraftProTable.module.css +78 -0
  104. package/template-vp-monorepo-react-nestjs/apps/web/src/components/DraftProTable/DraftProTable.tsx +99 -0
  105. package/template-vp-monorepo-react-nestjs/apps/web/src/components/DraftProTable/README.md +34 -0
  106. package/template-vp-monorepo-react-nestjs/apps/web/src/components/FullHeightProTable/FullHeightProTable.module.css +54 -0
  107. package/template-vp-monorepo-react-nestjs/apps/web/src/components/FullHeightProTable/FullHeightProTable.tsx +41 -0
  108. package/template-vp-monorepo-react-nestjs/apps/web/src/components/Icon/svg-icon/README.md +37 -0
  109. package/template-vp-monorepo-react-nestjs/apps/web/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  110. package/template-vp-monorepo-react-nestjs/apps/web/src/components/Loading/PageLoading.module.css +7 -0
  111. package/template-vp-monorepo-react-nestjs/apps/web/src/components/Loading/PageLoading.tsx +2 -1
  112. package/template-vp-monorepo-react-nestjs/apps/web/src/config/theme.ts +20 -0
  113. package/template-vp-monorepo-react-nestjs/apps/web/src/layouts/BasicLayout.module.css +17 -0
  114. package/template-vp-monorepo-react-nestjs/apps/web/src/layouts/BasicLayout.tsx +106 -0
  115. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/i18n/index.module.css +23 -0
  116. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/i18n/index.tsx +53 -0
  117. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/components/ProjectFormDialog.tsx +132 -0
  118. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/config/columns.tsx +121 -0
  119. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/config/index.ts +77 -0
  120. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/components/DraftProjectFormDialog.tsx +140 -0
  121. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/config/columns.tsx +127 -0
  122. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/config/index.ts +39 -0
  123. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/config/projects.ts +48 -0
  124. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/index.module.css +49 -0
  125. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/index.tsx +163 -0
  126. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/index.module.css +53 -0
  127. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/index.tsx +135 -0
  128. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/home/index.module.css +23 -0
  129. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/home/index.tsx +26 -43
  130. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/login/api.ts +11 -0
  131. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/login/index.tsx +183 -0
  132. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/login/login.css +164 -0
  133. package/template-vp-monorepo-react-nestjs/apps/web/src/router/index.tsx +36 -12
  134. package/template-vp-monorepo-react-nestjs/apps/web/src/styles/index.css +11 -4
  135. package/template-vp-monorepo-react-nestjs/apps/web/src/utils/request/core/index.ts +55 -47
  136. package/template-vp-monorepo-react-nestjs/apps/web/src/utils/request/index.ts +10 -5
  137. package/template-vp-monorepo-react-nestjs/apps/web/src/utils/storage/cookie.ts +50 -0
  138. package/template-vp-monorepo-react-nestjs/apps/web/src/utils/storage/session.ts +33 -0
  139. package/template-vp-monorepo-react-nestjs/apps/web/test/draft-projects.spec.ts +89 -0
  140. package/template-vp-monorepo-react-nestjs/apps/web/test/request.spec.ts +145 -0
  141. package/template-vp-monorepo-react-nestjs/apps/web/test/storage.spec.ts +108 -0
  142. package/template-vp-monorepo-react-nestjs/apps/web/test/tsconfig.json +7 -0
  143. package/template-vp-monorepo-react-nestjs/apps/web/tsconfig.json +1 -1
  144. package/template-vp-monorepo-react-nestjs/apps/web/vite.config.ts +7 -0
  145. package/template-vp-monorepo-react-nestjs/apps/web-vue/tsconfig.tsbuildinfo +1 -0
  146. package/template-vp-monorepo-react-nestjs/docker-compose.yml +19 -0
  147. package/template-vp-monorepo-react-nestjs/mise.toml +1 -1
  148. package/template-vp-monorepo-react-nestjs/package.json +1 -6
  149. package/template-vp-monorepo-react-nestjs/pnpm-workspace.yaml +9 -1
  150. package/template-vp-react/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  151. package/template-vp-react/AGENTS.md +11 -0
  152. package/template-vp-react/commitlint.config.js +0 -0
  153. package/template-vp-react/package.json +21 -26
  154. package/template-vp-react/pnpm-workspace.yaml +6 -0
  155. package/template-vp-react/src/assets/svg/draft.svg +4 -0
  156. package/template-vp-react/src/components/Icon/svg-icon/README.md +37 -0
  157. package/template-vp-react/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  158. package/template-vp-react/src/utils/request/index.ts +18 -5
  159. package/template-vp-react/tsconfig.json +2 -3
  160. package/template-vp-react/vite.config.ts +2 -0
  161. package/template-vp-react-shadcn/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  162. package/template-vp-react-shadcn/.vscode/settings.json +2 -2
  163. package/template-vp-react-shadcn/{agents.md → AGENTS.md} +12 -2
  164. package/template-vp-react-shadcn/README.md +41 -0
  165. package/template-vp-react-shadcn/commitlint.config.js +1 -1
  166. package/template-vp-react-shadcn/components.json +1 -1
  167. package/template-vp-react-shadcn/package.json +25 -32
  168. package/template-vp-react-shadcn/pnpm-workspace.yaml +10 -0
  169. package/template-vp-react-shadcn/src/App.tsx +10 -10
  170. package/template-vp-react-shadcn/src/assets/svg/draft.svg +4 -0
  171. package/template-vp-react-shadcn/src/components/Icon/svg-icon/README.md +37 -0
  172. package/template-vp-react-shadcn/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  173. package/template-vp-react-shadcn/src/components/Loading/PageLoading.tsx +4 -4
  174. package/template-vp-react-shadcn/src/components/Player/VideoJS/index.tsx +94 -78
  175. package/template-vp-react-shadcn/src/components/Player/index.ts +1 -1
  176. package/template-vp-react-shadcn/src/components/ui/button.tsx +25 -32
  177. package/template-vp-react-shadcn/src/components/ui/spinner.tsx +8 -7
  178. package/template-vp-react-shadcn/src/components/ui/toast.tsx +229 -0
  179. package/template-vp-react-shadcn/src/lib/utils.ts +3 -3
  180. package/template-vp-react-shadcn/src/main.tsx +5 -4
  181. package/template-vp-react-shadcn/src/pages/home/index.tsx +43 -35
  182. package/template-vp-react-shadcn/src/router/index.tsx +15 -15
  183. package/template-vp-react-shadcn/src/styles/index.css +4 -4
  184. package/template-vp-react-shadcn/src/styles/shadcn.css +2 -2
  185. package/template-vp-react-shadcn/src/utils/env/index.tsx +2 -2
  186. package/template-vp-react-shadcn/src/utils/request/alova-core/index.ts +102 -30
  187. package/template-vp-react-shadcn/src/utils/request/alova-core/utils.ts +5 -2
  188. package/template-vp-react-shadcn/src/utils/request/index.ts +32 -19
  189. package/template-vp-react-shadcn/src/utils/request/readme.md +41 -38
  190. package/template-vp-react-shadcn/tsconfig.json +2 -3
  191. package/template-vp-react-shadcn/vite.config.ts +29 -15
  192. package/template-vp-vue-eslint-vapor/package.json +26 -33
  193. package/template-vp-vue-eslint-vapor/pnpm-workspace.yaml +29 -1
  194. package/template-vue-vp-eslint/README.md +3 -10
  195. package/template-vue-vp-eslint/package.json +27 -34
  196. package/template-vue-vp-eslint/pnpm-workspace.yaml +27 -2
  197. package/template-vue-vp-eslint/src/layout/default/index.vue +4 -3
  198. package/dist/index.mjs +0 -422
  199. package/template-vp-monorepo-react-nestjs/.agents/auth.config.ts +0 -0
  200. package/template-vp-monorepo-react-nestjs/.spaces/server/todo.md +0 -991
  201. package/template-vp-monorepo-react-nestjs/apps/server/README.md +0 -3
  202. package/template-vp-react-shadcn/.oxfmtrc.jsonc +0 -8
  203. package/template-vp-react-shadcn/.oxlintrc.jsonc +0 -3
  204. package/template-vp-react-shadcn/src/components/ui/sonner.tsx +0 -43
@@ -1,16 +1,12 @@
1
- <!--VITE PLUS START-->
1
+ ## 目录说明
2
2
 
3
- # Using Vite+, the Unified Toolchain for the Web
3
+ - 修改文件前,须从文件所在目录逐级向上查找并阅读相关的 `AGENTS.md`(如存在),并遵循其中的说明。
4
4
 
5
- This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called `vp`. Vite+ is distinct from Vite, and it invokes Vite through `vp dev` and `vp build`. Run `vp help` to print a list of commands and `vp <command> --help` for information about a specific command.
5
+ ## 按需规则
6
6
 
7
- Docs are local at `node_modules/vite-plus/docs` or online at https://viteplus.dev/guide/.
7
+ 根据当前任务匹配下表,在执行相关操作前读取对应规则;命中多项时分别读取。不要预先加载整个 `.agents/rules/` 目录;任务范围变化时补读新命中的规则。
8
8
 
9
- ## Review Checklist
10
-
11
- - [ ] Run `vp install` after pulling remote changes and before getting started.
12
- - [ ] Run `vp check` and `vp test` to format, lint, type check and test changes.
13
- - [ ] Check if there are `vite.config.ts` tasks or `package.json` scripts necessary for validation, run via `vp run <script>`.
14
- - [ ] If setup, runtime, or package-manager behavior looks wrong, run `vp env doctor` and include its output when asking for help.
15
-
16
- <!--VITE PLUS END-->
9
+ | 适用条件 | 规则文件 |
10
+ | -------------------------------------------------------------- | ------------------------------------- |
11
+ | 新增、修改或重构前后端代码 | [代码设计](.agents/rules/代码设计.md) |
12
+ | 定义或调整前后端接口类型、返回类型,或新增、修改、抽取公用方法 | [共享代码](.agents/rules/共享代码.md) |
@@ -0,0 +1,84 @@
1
+ # Server 错误处理规则
2
+
3
+ 本规则供 AI 修改 `apps/server` 时执行。
4
+
5
+ ## 默认策略
6
+
7
+ 如果客户端不需要特定错误码、文案或 HTTP 状态:
8
+
9
+ - 不要 `catch`。
10
+ - 不要手动包装成 `AppException`。
11
+ - 让异常直接向上冒泡。
12
+ - 由 `GlobalExceptionFilter` 统一记录日志并返回 `COMMON.INTERNAL_SERVER_ERROR` 和 HTTP 500。
13
+
14
+ ```ts
15
+ // 正确:没有特殊输出要求,直接交给全局异常过滤器
16
+ const user = await this.userRepository.findById(userId)
17
+ ```
18
+
19
+ 本项目实际使用的是全局异常过滤器 `GlobalExceptionFilter`,业务代码不要重复实现统一错误响应。
20
+
21
+ ## 什么时候使用 AppException
22
+
23
+ 只有以下情况使用 `AppException`:
24
+
25
+ 1. 客户端需要识别明确的业务错误,例如账号已存在、登录失效、资源不存在。
26
+ 2. 外部依赖失败必须明确返回模块级 HTTP 503。
27
+ 3. 需要返回安全的字段错误 `details`。
28
+
29
+ ```ts
30
+ if (!user) {
31
+ throw new AppException(USER_ERRORS.NOT_FOUND)
32
+ }
33
+ ```
34
+
35
+ 模块错误定义在对应的 `*.errors.ts`:
36
+
37
+ ```ts
38
+ export const USER_ERRORS = {
39
+ NOT_FOUND: {
40
+ code: 'USER.NOT_FOUND',
41
+ publicMessage: '用户不存在',
42
+ status: HttpStatus.NOT_FOUND,
43
+ },
44
+ } as const satisfies Record<string, AppErrorDefinition>
45
+ ```
46
+
47
+ 错误码必须全局唯一、采用大写 `模块.错误名称` 格式。公开文案不得包含堆栈、SQL、Redis 数据、连接信息、令牌或底层错误文本。HTTP 401 必须设置 `bearerChallenge: true`。
48
+
49
+ ## 基础设施错误
50
+
51
+ 默认让数据库、Redis 和第三方 SDK 的未知异常交给全局过滤器处理。
52
+
53
+ 只有明确要求返回模块级 503 时,才在最接近依赖的边界转换一次:
54
+
55
+ ```ts
56
+ try {
57
+ return await operation()
58
+ } catch (cause: unknown) {
59
+ if (cause instanceof AppException) {
60
+ throw cause
61
+ }
62
+
63
+ throw new AppException(USER_ERRORS.SERVICE_UNAVAILABLE, { cause })
64
+ }
65
+ ```
66
+
67
+ 不要:
68
+
69
+ - 在每个数据库或 Redis 调用后添加 `.catch()`。
70
+ - 外层已经转换错误,内层再次包装。
71
+ - 捕获后只记录日志再抛出;全局过滤器已负责 5xx 日志。
72
+ - 把整个业务流程包装成 503,导致程序错误被伪装成服务不可用。
73
+
74
+ `catch` 仅用于错误语义转换、事务回滚、资源清理、重试或明确降级。
75
+
76
+ ## 相关文件
77
+
78
+ - `src/common/exceptions/app.exception.ts`:`AppException`。
79
+ - `src/common/error/common.error.ts`:公共错误。
80
+ - `src/modules/*/*.errors.ts`:模块错误。
81
+ - `src/common/filters/global-exception.filter.ts`:统一异常处理。
82
+ - `test/error-catalog.spec.ts`:错误码校验。
83
+
84
+ 新增错误目录后,将其加入 `error-catalog.spec.ts`,然后运行 `vp check`、`vp test` 和 `vp run build`。如果检查被无关的既有问题阻塞,只报告问题,不要擅自批量修改无关文件。
@@ -23,3 +23,63 @@ REDIS_DB=0
23
23
  SESSION_TOKEN_PEPPER=EfN6+CbfvlXkxp9SeTkFpziHPtr0/krxZItsjqUCc7AnbH9cmnDXNSFeNpa78Z42
24
24
  SESSION_IDLE_TTL_SECONDS=7200
25
25
  SESSION_ABSOLUTE_TTL_SECONDS=604800
26
+
27
+
28
+ #MINIO
29
+ STORAGE_ENDPOINT=http://127.0.0.1:9000
30
+ STORAGE_REGION=us-east-1
31
+ STORAGE_ACCESS_KEY_ID=minio
32
+ STORAGE_SECRET_ACCESS_KEY=minio123456
33
+ STORAGE_BUCKET=uploads
34
+
35
+ # ==================== BullMQ 基础连接 ====================
36
+
37
+ # BullMQ 使用的 Redis 主机地址;本地开发通常为 localhost
38
+ QUEUE_REDIS_HOST=localhost
39
+ # Redis 服务端口;Redis 默认端口为 6379
40
+ QUEUE_REDIS_PORT=6379
41
+ # Redis ACL 用户名;留空表示使用 Redis 的 default 用户
42
+ QUEUE_REDIS_USERNAME=
43
+ # Redis 密码;生产环境应通过安全方式注入,不要提交真实密码
44
+ QUEUE_REDIS_PASSWORD=ml
45
+ # Redis 逻辑数据库编号;使用 DB 1,避免与默认 DB 0 的数据混在一起
46
+ QUEUE_REDIS_DB=1
47
+ # BullMQ 在 Redis 中创建键时使用的统一前缀
48
+ # 用于区分不同项目和环境,例如开发、测试、生产环境
49
+ QUEUE_PREFIX=bubbles:development:queue
50
+
51
+
52
+ # ==================== Worker 开关 ====================
53
+
54
+ # 当前 NestJS 进程是否启动 BullMQ Worker 并消费任务
55
+ # true:既可以投递任务,也会执行任务
56
+ # false:只投递任务,不在当前进程中执行任务
57
+ QUEUE_WORKER_ENABLED=true
58
+
59
+
60
+ # ==================== 默认任务策略 ====================
61
+
62
+ # 单个任务最多尝试执行的总次数
63
+ # 3 表示首次执行失败后最多再重试 2 次,共执行最多 3 次
64
+ QUEUE_DEFAULT_ATTEMPTS=3
65
+
66
+ # 任务失败后的重试退避基础延迟,单位为毫秒
67
+ # 1000 表示基础延迟为 1 秒
68
+ # 实际是固定延迟还是指数递增,取决于代码中的 backoff 类型配置
69
+ QUEUE_BACKOFF_DELAY_MS=1000
70
+
71
+ # 已完成任务记录的最长保留时间,单位为秒
72
+ # 86400 秒等于 24 小时,超过后可从 Redis 中清理
73
+ QUEUE_COMPLETED_AGE_SECONDS=86400
74
+
75
+ # Redis 中最多保留的已完成任务记录数量
76
+ # 即使任务未超过保留时间,也只保留最近约 1000 条
77
+ QUEUE_COMPLETED_COUNT=1000
78
+
79
+ # 失败任务记录的最长保留时间,单位为秒
80
+ # 604800 秒等于 7 天,便于排查近期失败原因
81
+ QUEUE_FAILED_AGE_SECONDS=604800
82
+
83
+ # Redis 中最多保留的失败任务记录数量
84
+ # 防止失败记录持续累积,占用过多 Redis 内存
85
+ QUEUE_FAILED_COUNT=5000
@@ -18,3 +18,19 @@ REDIS_HOST=localhost
18
18
  REDIS_PORT=6379
19
19
  REDIS_PASSWORD=ml
20
20
  REDIS_DB=0
21
+
22
+ # BullMQ 队列
23
+ # 下面两个 YOUR_... 都只是占位值,必须由部署配置或 Secret 替换
24
+ QUEUE_REDIS_HOST=YOUR_QUEUE_REDIS_HOST
25
+ QUEUE_REDIS_PORT=6379
26
+ QUEUE_REDIS_USERNAME=
27
+ QUEUE_REDIS_PASSWORD=YOUR_PRODUCTION_QUEUE_REDIS_PASSWORD
28
+ QUEUE_REDIS_DB=0
29
+ QUEUE_PREFIX=bubbles:production:queue
30
+ QUEUE_WORKER_ENABLED=true
31
+ QUEUE_DEFAULT_ATTEMPTS=3
32
+ QUEUE_BACKOFF_DELAY_MS=1000
33
+ QUEUE_COMPLETED_AGE_SECONDS=86400
34
+ QUEUE_COMPLETED_COUNT=1000
35
+ QUEUE_FAILED_AGE_SECONDS=604800
36
+ QUEUE_FAILED_COUNT=5000
@@ -0,0 +1,9 @@
1
+ # Server
2
+
3
+ ## 开发规范
4
+
5
+ 关于错误定义、异常抛出、`catch` 边界和全局异常处理,请阅读 [Server 错误处理规则](./.agents/rules/error-handling.md)。
6
+
7
+ ## 变更说明
8
+
9
+ - 用户主要从事前端开发。每次完成更改后,须在回复末尾说明本次改动涉及的重要知识点,尤其是后端知识和常见面试问题。
@@ -0,0 +1,11 @@
1
+ CREATE TYPE "public"."user_status" AS ENUM('active', 'locked', 'disabled');--> statement-breakpoint
2
+ CREATE TABLE "users" (
3
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
4
+ "name" varchar(100) NOT NULL,
5
+ "account" varchar(32) NOT NULL,
6
+ "password_hash" varchar(255) NOT NULL,
7
+ "status" "user_status" DEFAULT 'active' NOT NULL,
8
+ "create_at" timestamp DEFAULT now() NOT NULL,
9
+ "update_at" timestamp with time zone DEFAULT now() NOT NULL,
10
+ CONSTRAINT "users_account_unique" UNIQUE("account")
11
+ );
@@ -0,0 +1,27 @@
1
+ CREATE TYPE "public"."upload_status" AS ENUM('uploading', 'completing', 'completed', 'aborting', 'aborted', 'expired');--> statement-breakpoint
2
+ CREATE TABLE "upload_sessions" (
3
+ "id" uuid PRIMARY KEY NOT NULL,
4
+ "owner_id" uuid NOT NULL,
5
+ "client_upload_id" uuid NOT NULL,
6
+ "bucket" varchar(63) NOT NULL,
7
+ "object_key" varchar(1024) NOT NULL,
8
+ "storage_upload_id" text NOT NULL,
9
+ "original_name" varchar(255) NOT NULL,
10
+ "content_type" varchar(255) NOT NULL,
11
+ "file_size" bigint NOT NULL,
12
+ "part_size" integer NOT NULL,
13
+ "total_parts" integer NOT NULL,
14
+ "status" "upload_status" DEFAULT 'uploading' NOT NULL,
15
+ "expires_at" timestamp with time zone NOT NULL,
16
+ "object_etag" text,
17
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
18
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
19
+ "completed_at" timestamp with time zone
20
+ );
21
+ --> statement-breakpoint
22
+ ALTER TABLE "upload_sessions" ADD CONSTRAINT "upload_sessions_owner_id_users_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
23
+ CREATE UNIQUE INDEX "upload_sessions_owner_client_uq" ON "upload_sessions" USING btree ("owner_id","client_upload_id");--> statement-breakpoint
24
+ CREATE UNIQUE INDEX "upload_sessions_bucket_key_uq" ON "upload_sessions" USING btree ("bucket","object_key");--> statement-breakpoint
25
+ CREATE INDEX "upload_sessions_owner_status_expires_idx" ON "upload_sessions" USING btree ("owner_id","status","expires_at");--> statement-breakpoint
26
+ CREATE INDEX "upload_sessions_status_expires_idx" ON "upload_sessions" USING btree ("status","expires_at");--> statement-breakpoint
27
+ CREATE INDEX "upload_sessions_status_updated_idx" ON "upload_sessions" USING btree ("status","updated_at");
@@ -0,0 +1,97 @@
1
+ {
2
+ "id": "4efaf73b-a515-4481-80da-b95ba325bf9f",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.users": {
8
+ "name": "users",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "default": "gen_random_uuid()"
17
+ },
18
+ "name": {
19
+ "name": "name",
20
+ "type": "varchar(100)",
21
+ "primaryKey": false,
22
+ "notNull": true
23
+ },
24
+ "account": {
25
+ "name": "account",
26
+ "type": "varchar(32)",
27
+ "primaryKey": false,
28
+ "notNull": true
29
+ },
30
+ "password_hash": {
31
+ "name": "password_hash",
32
+ "type": "varchar(255)",
33
+ "primaryKey": false,
34
+ "notNull": true
35
+ },
36
+ "status": {
37
+ "name": "status",
38
+ "type": "user_status",
39
+ "typeSchema": "public",
40
+ "primaryKey": false,
41
+ "notNull": true,
42
+ "default": "'active'"
43
+ },
44
+ "create_at": {
45
+ "name": "create_at",
46
+ "type": "timestamp",
47
+ "primaryKey": false,
48
+ "notNull": true,
49
+ "default": "now()"
50
+ },
51
+ "update_at": {
52
+ "name": "update_at",
53
+ "type": "timestamp with time zone",
54
+ "primaryKey": false,
55
+ "notNull": true,
56
+ "default": "now()"
57
+ }
58
+ },
59
+ "indexes": {},
60
+ "foreignKeys": {},
61
+ "compositePrimaryKeys": {},
62
+ "uniqueConstraints": {
63
+ "users_account_unique": {
64
+ "name": "users_account_unique",
65
+ "nullsNotDistinct": false,
66
+ "columns": [
67
+ "account"
68
+ ]
69
+ }
70
+ },
71
+ "policies": {},
72
+ "checkConstraints": {},
73
+ "isRLSEnabled": false
74
+ }
75
+ },
76
+ "enums": {
77
+ "public.user_status": {
78
+ "name": "user_status",
79
+ "schema": "public",
80
+ "values": [
81
+ "active",
82
+ "locked",
83
+ "disabled"
84
+ ]
85
+ }
86
+ },
87
+ "schemas": {},
88
+ "sequences": {},
89
+ "roles": {},
90
+ "policies": {},
91
+ "views": {},
92
+ "_meta": {
93
+ "columns": {},
94
+ "schemas": {},
95
+ "tables": {}
96
+ }
97
+ }