create-bubbles 0.1.20 → 0.1.22
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.
- package/dist/{index.js → index.mjs} +9 -7
- package/package.json +5 -4
- package/template-nextjs-vinext-eslint/vite.config.ts +1 -1
- package/template-vp-monorepo-react-nestjs/.spaces/server//347/231/273/345/275/225/JWT/344/270/216RefreshToken/350/275/256/346/215/242/351/211/264/346/235/203/346/236/266/346/236/204/345/256/236/347/216/260/346/214/207/345/215/227.md +6614 -0
- package/template-vp-monorepo-react-nestjs/.vite-hooks/commit-msg +1 -0
- package/template-vp-monorepo-react-nestjs/.vite-hooks/pre-commit +2 -1
- package/template-vp-monorepo-react-nestjs/.vscode/settings.json +25 -0
- package/template-vp-monorepo-react-nestjs/AGENTS.md +16 -0
- package/template-vp-monorepo-react-nestjs/README.md +2 -2
- package/template-vp-monorepo-react-nestjs/apps/server/.env.development +61 -0
- package/template-vp-monorepo-react-nestjs/apps/server/.env.production +20 -0
- package/template-vp-monorepo-react-nestjs/apps/server/README.md +3 -0
- package/template-vp-monorepo-react-nestjs/apps/server/drizzle.config.ts +15 -0
- package/template-vp-monorepo-react-nestjs/apps/server/nest-cli.json +8 -0
- package/template-vp-monorepo-react-nestjs/apps/server/package.json +57 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/app.controller.ts +12 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/app.module.ts +58 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/app.service.ts +8 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/common/constants/decorator.ts +2 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/common/constants/response.ts +15 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/common/decorators/bypass.ts +12 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/common/interceptors/transform.ts +34 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/common/model/response.ts +23 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/config/app.config.ts +6 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/config/auth.config.ts +64 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/config/database.config.ts +10 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/config/index.ts +5 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/config/llm.config.ts +7 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/config/redis.config.ts +18 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/database/db.module.ts +32 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/database/schema.ts +14 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/main.ts +34 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/db/db.controller.ts +28 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/db/db.module.ts +9 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/db/db.service.ts +22 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/db/dto/create-user.dto.ts +27 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/redis/dto/redis-quary.dto.ts +18 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/redis/redis.controller.ts +31 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/redis/redis.module.ts +9 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/redis/redis.service.ts +37 -0
- package/template-vp-monorepo-react-nestjs/apps/server/src/utils/server-address.ts +33 -0
- package/template-vp-monorepo-react-nestjs/apps/server/tsconfig.build.json +4 -0
- package/template-vp-monorepo-react-nestjs/apps/server/tsconfig.json +28 -0
- package/template-vp-monorepo-react-nestjs/apps/web/.env +1 -0
- package/template-vp-monorepo-react-nestjs/apps/web/.env.dev +1 -0
- package/template-vp-monorepo-react-nestjs/apps/web/.env.prod +1 -0
- package/template-vp-monorepo-react-nestjs/apps/web/package.json +21 -25
- package/template-vp-monorepo-react-nestjs/apps/web/src/App.tsx +5 -4
- package/template-vp-monorepo-react-nestjs/apps/web/src/locales/en_US.json +4 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/locales/zh_CN.json +4 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/main.tsx +4 -4
- package/template-vp-monorepo-react-nestjs/apps/web/src/pages/home/index.tsx +38 -8
- package/template-vp-monorepo-react-nestjs/apps/web/src/router/index.tsx +15 -15
- package/template-vp-monorepo-react-nestjs/apps/web/src/utils/env/index.ts +6 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/utils/request/core/index.ts +420 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/utils/request/core/utils.ts +39 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/utils/request/index.ts +61 -0
- package/template-vp-monorepo-react-nestjs/apps/web/tsconfig.json +10 -14
- package/template-vp-monorepo-react-nestjs/apps/web/vite.config.ts +15 -2
- package/template-vp-monorepo-react-nestjs/apps/web-vue/.env.production +2 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/.vscode/extensions.json +3 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/AGENTS.md +16 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/README.md +98 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/commitlint.config.js +1 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/eslint.config.js +13 -0
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/lefthook.yml +1 -1
- package/template-vp-monorepo-react-nestjs/apps/web-vue/package.json +67 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/pnpm-workspace.yaml +16 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/App.vue +12 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/api/index.ts +12 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/assets/image/.gitkeep +0 -0
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/components/Icon/svg-icon.vue +3 -3
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/hooks/chart/lib.ts +6 -6
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/hooks/chart/useEcharts.ts +65 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/i18n/instance.ts +8 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/layout/default/header/index.vue +30 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/layout/default/index.vue +138 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/locales/en_US.json +4 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/locales/zh_CN.json +4 -0
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/main.ts +0 -3
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/router/guard/index.ts +7 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/router/guard/permissionGuard.ts +13 -0
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/router/index.ts +7 -7
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/router/interface.ts +9 -0
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/router/modules/index.ts +1 -4
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/store/index.ts +11 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/store/modules/user.ts +17 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/styles/font.scss +0 -0
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/styles/index.scss +3 -3
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/types/components.d.ts +8 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/types/vite-env.d.ts +15 -0
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/utils/env.ts +1 -1
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/utils/request/index.ts +5 -3
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/views/example/echart/config.ts +687 -687
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/views/example/echart/index.vue +20 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/views/example/tree-chart.vue +16 -0
- package/template-vp-monorepo-react-nestjs/apps/web-vue/src/views/home/index.vue +27 -0
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/tsconfig.json +2 -9
- package/template-vp-monorepo-react-nestjs/apps/web-vue/uno.config.ts +17 -0
- package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/vite.config.ts +4 -6
- package/template-vp-monorepo-react-nestjs/commitlint.config.js +0 -0
- package/template-vp-monorepo-react-nestjs/docker-compose.yml +41 -0
- package/template-vp-monorepo-react-nestjs/mise.toml +3 -0
- package/template-vp-monorepo-react-nestjs/package.json +16 -11
- package/template-vp-monorepo-react-nestjs/packages/i18n/core/package.json +20 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/core/src/format.ts +9 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/core/src/i18n.ts +73 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/core/src/index.ts +24 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/core/src/storage.ts +47 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/core/src/store.ts +48 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/core/src/types.ts +36 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/core/tsconfig.json +15 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/core/vite.config.ts +13 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/react/package.json +28 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/react/src/index.tsx +26 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/react/src/use-store.ts +14 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/react/tsconfig.json +16 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/react/vite.config.ts +16 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/vue/package.json +27 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/vue/src/index.ts +52 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/vue/src/use-store.ts +19 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/vue/tsconfig.json +15 -0
- package/template-vp-monorepo-react-nestjs/packages/i18n/vue/vite.config.ts +16 -0
- package/template-vp-monorepo-react-nestjs/pnpm-workspace.yaml +97 -9
- package/template-vp-monorepo-react-nestjs/vite.config.ts +15 -4
- package/template-vue-vp-eslint/.env +6 -0
- package/template-vue-vp-eslint/.env.development +2 -0
- package/template-vue-vp-eslint/.env.production +2 -0
- package/template-vue-vp-eslint/.vscode/extensions.json +3 -0
- package/template-vue-vp-eslint/AGENTS.md +16 -0
- package/template-vue-vp-eslint/README.md +98 -0
- package/template-vue-vp-eslint/commitlint.config.js +1 -0
- package/template-vue-vp-eslint/eslint.config.js +13 -0
- package/template-vue-vp-eslint/index.html +13 -0
- package/template-vue-vp-eslint/lefthook.yml +11 -0
- package/template-vue-vp-eslint/package.json +63 -0
- package/template-vue-vp-eslint/pnpm-workspace.yaml +3 -0
- package/template-vue-vp-eslint/public/vite.svg +1 -0
- package/template-vue-vp-eslint/src/App.vue +7 -0
- package/template-vue-vp-eslint/src/api/index.ts +12 -0
- package/template-vue-vp-eslint/src/assets/icon/home.svg +3 -0
- package/template-vue-vp-eslint/src/assets/icon/logo.svg +1 -0
- package/template-vue-vp-eslint/src/assets/image/.gitkeep +0 -0
- package/template-vue-vp-eslint/src/components/Icon/svg-icon.vue +29 -0
- package/template-vue-vp-eslint/src/hooks/chart/lib.ts +57 -0
- package/template-vue-vp-eslint/src/hooks/chart/useEcharts.ts +65 -0
- package/template-vue-vp-eslint/src/layout/default/header/index.vue +30 -0
- package/template-vue-vp-eslint/src/layout/default/index.vue +138 -0
- package/template-vue-vp-eslint/src/main.ts +16 -0
- package/template-vue-vp-eslint/src/router/guard/index.ts +7 -0
- package/{template-vue-vite-eslint → template-vue-vp-eslint}/src/router/guard/permissionGuard.ts +3 -3
- package/template-vue-vp-eslint/src/router/index.ts +18 -0
- package/template-vue-vp-eslint/src/router/interface.ts +9 -0
- package/template-vue-vp-eslint/src/router/modules/index.ts +33 -0
- package/template-vue-vp-eslint/src/store/index.ts +11 -0
- package/template-vue-vp-eslint/src/store/modules/user.ts +17 -0
- package/template-vue-vp-eslint/src/styles/font.scss +0 -0
- package/template-vue-vp-eslint/src/styles/index.scss +29 -0
- package/template-vue-vp-eslint/src/styles/variables.scss +3 -0
- package/template-vue-vp-eslint/src/types/vite-env.d.ts +15 -0
- package/template-vue-vp-eslint/src/utils/env.ts +11 -0
- package/template-vue-vp-eslint/src/utils/request/core/index.ts +425 -0
- package/template-vue-vp-eslint/src/utils/request/core/utils.ts +39 -0
- package/template-vue-vp-eslint/src/utils/request/index.ts +44 -0
- package/template-vue-vp-eslint/src/views/example/echart/config.ts +1794 -0
- package/template-vue-vp-eslint/src/views/example/echart/index.vue +20 -0
- package/template-vue-vp-eslint/src/views/example/tree-chart.vue +16 -0
- package/template-vue-vp-eslint/src/views/home/index.vue +16 -0
- package/template-vue-vp-eslint/src/views/login/index.vue +9 -0
- package/template-vue-vp-eslint/tsconfig.json +29 -0
- package/template-vue-vp-eslint/uno.config.ts +17 -0
- package/template-vue-vp-eslint/vite.config.ts +58 -0
- package/template-vp-monorepo-react-nestjs/.oxfmtrc.jsonc +0 -8
- package/template-vp-monorepo-react-nestjs/.oxlintrc.jsonc +0 -3
- package/template-vp-monorepo-react-nestjs/.specs//351/234/200/346/261/202.md +0 -5
- package/template-vp-monorepo-react-nestjs/apps/service/.oxlintrc.jsonc +0 -3
- package/template-vp-monorepo-react-nestjs/apps/web/.oxlintrc.jsonc +0 -4
- package/template-vp-monorepo-react-nestjs/packages/utils/README.md +0 -23
- package/template-vp-monorepo-react-nestjs/packages/utils/package.json +0 -39
- package/template-vp-monorepo-react-nestjs/packages/utils/src/index.ts +0 -3
- package/template-vp-monorepo-react-nestjs/packages/utils/tests/index.test.ts +0 -6
- package/template-vp-monorepo-react-nestjs/packages/utils/tsconfig.json +0 -20
- package/template-vp-monorepo-react-nestjs/packages/utils/tsdown.config.ts +0 -9
- package/template-vp-monorepo-react-nestjs/packages/utils/vite.config.ts +0 -7
- package/template-vue-vite-eslint/.env.production +0 -1
- package/template-vue-vite-eslint/README.md +0 -3
- package/template-vue-vite-eslint/commitlint.config.js +0 -1
- package/template-vue-vite-eslint/eslint.config.js +0 -69
- package/template-vue-vite-eslint/package.json +0 -56
- package/template-vue-vite-eslint/src/App.vue +0 -19
- package/template-vue-vite-eslint/src/api/index.ts +0 -12
- package/template-vue-vite-eslint/src/hooks/chart/useEcharts.ts +0 -65
- package/template-vue-vite-eslint/src/layout/default/header/index.vue +0 -12
- package/template-vue-vite-eslint/src/layout/default/index.vue +0 -55
- package/template-vue-vite-eslint/src/router/guard/index.ts +0 -7
- package/template-vue-vite-eslint/src/router/interface.ts +0 -9
- package/template-vue-vite-eslint/src/router/modules/example.ts +0 -21
- package/template-vue-vite-eslint/src/store/index.ts +0 -11
- package/template-vue-vite-eslint/src/store/modules/user.ts +0 -20
- package/template-vue-vite-eslint/src/types/vite-env.d.ts +0 -15
- package/template-vue-vite-eslint/src/views/example/echart/index.vue +0 -22
- package/template-vue-vite-eslint/src/views/example/h-full.vue +0 -24
- package/template-vue-vite-eslint/src/views/example/tree-chart.vue +0 -94
- package/template-vue-vite-eslint/src/views/home/index.vue +0 -25
- package/template-vue-vite-eslint/uno.config.ts +0 -21
- /package/{template-vue-vite-eslint/src/assets/image/.gitkeep → template-vp-monorepo-react-nestjs/.agents/auth.config.ts} +0 -0
- /package/{template-vue-vite-eslint/src/styles/font.scss → template-vp-monorepo-react-nestjs/apps/server/src/config/security.config.ts} +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/.env +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/.env.development +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/index.html +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/public/vite.svg +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/assets/icon/computer-data.svg +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/assets/icon/cpu.svg +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/assets/icon/data-search.svg +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/assets/icon/home.svg +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/assets/icon/knowledge-graph.svg +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/assets/icon/logo.svg +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/assets/icon/robot.svg +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/styles/variables.scss +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/types/auto-import.d.ts +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/utils/request/core/index.ts +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/utils/request/core/utils.ts +0 -0
- /package/{template-vue-vite-eslint → template-vp-monorepo-react-nestjs/apps/web-vue}/src/views/login/index.vue +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DRIZZLE, type DrizzleDB } from '@/database/db.module'
|
|
2
|
+
import { Inject, Injectable } from '@nestjs/common'
|
|
3
|
+
import { users } from '@/database/schema'
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class DbService {
|
|
7
|
+
constructor(@Inject(DRIZZLE) private readonly db: DrizzleDB) {}
|
|
8
|
+
|
|
9
|
+
async ping() {
|
|
10
|
+
const res = await this.db.execute('SELECT now() AS now')
|
|
11
|
+
return res.rows[0]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async findAll() {
|
|
15
|
+
return this.db.query.users.findMany()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async create(data: Omit<typeof users.$inferInsert, 'id' | 'createdAt'>) {
|
|
19
|
+
const [row] = await this.db.insert(users).values(data).returning()
|
|
20
|
+
return row
|
|
21
|
+
}
|
|
22
|
+
}
|
package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/db/dto/create-user.dto.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { users } from '@/database/schema'
|
|
2
|
+
import { createInsertSchema } from 'drizzle-zod'
|
|
3
|
+
import { createZodDto } from 'nestjs-zod'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
/**
|
|
6
|
+
* 1. 基于数据库表生成zod schema
|
|
7
|
+
* drizzle-zod 会自动把 varchar({ length: 100 }) 翻成 .max(100)
|
|
8
|
+
* 把notNull 翻成 必填字段
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const baseSchema = createInsertSchema(users, {
|
|
12
|
+
// 数据库不知道邮箱格式, 这里用zod增强
|
|
13
|
+
email: z.email(),
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 2. 创建用户的入参不应该包括 id 和 createdAt(这两数据库自动生成)
|
|
18
|
+
*/
|
|
19
|
+
export const createUserSchema = baseSchema.omit({
|
|
20
|
+
id: true,
|
|
21
|
+
createdAt: true,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 3. 包成nestjs dto
|
|
26
|
+
*/
|
|
27
|
+
export class CreateUserDto extends createZodDto(createUserSchema) {}
|
package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/redis/dto/redis-quary.dto.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { createZodDto } from 'nestjs-zod'
|
|
3
|
+
|
|
4
|
+
// GET /redis/set?key=name&value=tom&ttl=60
|
|
5
|
+
export const SetQuerySchema = z.object({
|
|
6
|
+
key: z.string().min(1, 'key不能为空'),
|
|
7
|
+
value: z.string().min(1, 'value不能为空'),
|
|
8
|
+
// url 查询参数都是字符串, z coerce.number() 会自动把 “60” 转换为 60
|
|
9
|
+
ttl: z.coerce.number().int().positive('ttl 必须是正整数').optional(),
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export class SetQueryDto extends createZodDto(SetQuerySchema) {}
|
|
13
|
+
|
|
14
|
+
export const GetQuerySchema = z.object({
|
|
15
|
+
key: z.string().min(1, 'key 不能为空'),
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export class GetQueryDto extends createZodDto(GetQuerySchema) {}
|
package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/redis/redis.controller.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Body, Controller, Get, Post, Query } from '@nestjs/common'
|
|
2
|
+
import { RedisService } from './redis.service'
|
|
3
|
+
import { ApiOperation, ApiTags } from '@nestjs/swagger'
|
|
4
|
+
import { GetQueryDto, SetQueryDto } from './dto/redis-quary.dto'
|
|
5
|
+
|
|
6
|
+
@ApiTags('Redis 测试')
|
|
7
|
+
@Controller('redis')
|
|
8
|
+
export class RedisController {
|
|
9
|
+
constructor(private readonly redisService: RedisService) {}
|
|
10
|
+
|
|
11
|
+
@ApiOperation({ summary: '测试 Redis 连接' })
|
|
12
|
+
@Get('ping')
|
|
13
|
+
async ping() {
|
|
14
|
+
return { pong: await this.redisService.ping() }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// GET /redis/set?key=name&value=tom&ttl=60
|
|
18
|
+
@ApiOperation({ summary: '设置键值对' })
|
|
19
|
+
@Post('set')
|
|
20
|
+
async set(@Body() body: SetQueryDto) {
|
|
21
|
+
await this.redisService.set(body.key, body.value, body.ttl ? Number(body.ttl) : undefined)
|
|
22
|
+
return { key: body.key, value: body.value, ttl: body.ttl ?? null }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// GET /redis/get?key=name
|
|
26
|
+
@ApiOperation({ summary: '获取键值对' })
|
|
27
|
+
@Get('get')
|
|
28
|
+
async get(@Query('key') query: GetQueryDto) {
|
|
29
|
+
return { key: query.key, value: await this.redisService.get(query.key) }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common'
|
|
2
|
+
import { InjectRedis } from '@nestjs-modules/ioredis'
|
|
3
|
+
import Redis from 'ioredis'
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class RedisService {
|
|
7
|
+
constructor(@InjectRedis() private readonly redis: Redis) {}
|
|
8
|
+
|
|
9
|
+
async ping() {
|
|
10
|
+
return this.redis.ping()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async set(key: string, value: string, ttlSeconds?: number) {
|
|
14
|
+
if (ttlSeconds && ttlSeconds > 0) {
|
|
15
|
+
await this.redis.set(key, value, 'EX', ttlSeconds)
|
|
16
|
+
} else {
|
|
17
|
+
await this.redis.set(key, value)
|
|
18
|
+
}
|
|
19
|
+
return 'Ok'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async get(key: string) {
|
|
23
|
+
return this.redis.get(key)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async del(key: string) {
|
|
27
|
+
return this.redis.del(key)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async exist(key: string) {
|
|
31
|
+
return (await this.redis.exists(key)) === 1
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async keys(pattern: string) {
|
|
35
|
+
return this.redis.keys(pattern)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { networkInterfaces } from 'os'
|
|
2
|
+
|
|
3
|
+
const color = {
|
|
4
|
+
cyan: (text: string) => `\x1b[36m${text}\x1b[0m`,
|
|
5
|
+
green: (text: string) => `\x1b[32m${text}\x1b[0m`,
|
|
6
|
+
bold: (text: string) => `\x1b[1m${text}\x1b[0m`,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function terminalLink(url: string) {
|
|
10
|
+
return `\x1b]8;;${url}\x1b\\${color.cyan(url)}\x1b]8;;\x1b\\`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getNetworkUrls(port: number) {
|
|
14
|
+
return Object.values(networkInterfaces())
|
|
15
|
+
.flatMap((items) => items ?? [])
|
|
16
|
+
.filter((item) => item.family === 'IPv4' && !item.internal)
|
|
17
|
+
.map((item) => `http://${item.address}:${port}/`)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 打印服务器网络地址
|
|
22
|
+
* @param port 服务器端口
|
|
23
|
+
*/
|
|
24
|
+
export function logNetworkUrls(port: number) {
|
|
25
|
+
const localUrl = `http://localhost:${port}/`
|
|
26
|
+
|
|
27
|
+
console.log(`\n ${color.bold(color.green('NEST'))} ${color.green('dev')}`)
|
|
28
|
+
console.log(` ${color.green('➜')} ${color.bold('Local:')} ${terminalLink(localUrl)}`)
|
|
29
|
+
|
|
30
|
+
for (const url of new Set(getNetworkUrls(port))) {
|
|
31
|
+
console.log(` ${color.green('➜')} ${color.bold('Network:')} ${terminalLink(url)}`)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "nodenext",
|
|
4
|
+
"moduleResolution": "nodenext",
|
|
5
|
+
"resolvePackageJsonExports": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"isolatedModules": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"removeComments": true,
|
|
10
|
+
"emitDecoratorMetadata": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"target": "ES2023",
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"outDir": "./dist",
|
|
16
|
+
"rootDir": "./",
|
|
17
|
+
"incremental": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"strictNullChecks": true,
|
|
20
|
+
"forceConsistentCasingInFileNames": true,
|
|
21
|
+
"noImplicitAny": false,
|
|
22
|
+
"strictBindCallApply": false,
|
|
23
|
+
"noFallthroughCasesInSwitch": false,
|
|
24
|
+
"paths": {
|
|
25
|
+
"@/*": ["./src/*"]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_API_URL = http://localhost:10000
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_API_URL = http://192.168.2.108:10000
|
|
@@ -1,39 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "web",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "vp dev",
|
|
8
|
-
"build": "tsc && vp build",
|
|
9
|
-
"preview": "vp preview"
|
|
10
|
-
"prepare": "vp config",
|
|
11
|
-
"check": "vp check"
|
|
7
|
+
"dev": "vp dev --mode dev",
|
|
8
|
+
"build": "tsc && vp build --mode dev",
|
|
9
|
+
"preview": "vp preview"
|
|
12
10
|
},
|
|
13
11
|
"dependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
12
|
+
"@alova/adapter-axios": "catalog:",
|
|
13
|
+
"@bubblesjs/i18n-core": "workspace:*",
|
|
14
|
+
"@bubblesjs/i18n-react": "workspace:*",
|
|
15
|
+
"@tailwindcss/vite": "catalog:",
|
|
16
|
+
"alova": "catalog:",
|
|
17
|
+
"antd": "catalog:",
|
|
18
|
+
"axios": "catalog:",
|
|
19
|
+
"classnames": "catalog:",
|
|
20
|
+
"dayjs": "catalog:",
|
|
21
|
+
"react": "catalog:",
|
|
22
|
+
"react-dom": "catalog:",
|
|
23
|
+
"react-router": "catalog:",
|
|
24
|
+
"tailwindcss": "catalog:"
|
|
22
25
|
},
|
|
23
26
|
"devDependencies": {
|
|
24
|
-
"@types/react": "
|
|
25
|
-
"@types/react-dom": "
|
|
26
|
-
"@vitejs/plugin-react": "
|
|
27
|
+
"@types/react": "catalog:",
|
|
28
|
+
"@types/react-dom": "catalog:",
|
|
29
|
+
"@vitejs/plugin-react": "catalog:",
|
|
27
30
|
"typescript": "catalog:",
|
|
28
|
-
"unplugin-auto-import": "
|
|
31
|
+
"unplugin-auto-import": "catalog:",
|
|
29
32
|
"vite": "catalog:",
|
|
30
33
|
"vite-plus": "catalog:"
|
|
31
|
-
},
|
|
32
|
-
"packageManager": "pnpm@10.33.0",
|
|
33
|
-
"pnpm": {
|
|
34
|
-
"overrides": {
|
|
35
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
36
|
-
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
|
|
37
|
-
}
|
|
38
34
|
}
|
|
39
35
|
}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { ConfigProvider } from 'antd'
|
|
2
|
-
import zhCN from 'antd/es/locale/zh_CN'
|
|
3
2
|
import dayjs from 'dayjs'
|
|
4
3
|
import 'dayjs/locale/zh-cn'
|
|
5
4
|
import { Suspense } from 'react'
|
|
6
5
|
import { RouterProvider } from 'react-router'
|
|
7
|
-
|
|
8
6
|
import PageLoading from '@/components/Loading/PageLoading'
|
|
9
|
-
|
|
10
7
|
import { router } from './router'
|
|
11
8
|
|
|
12
9
|
dayjs.locale('zh-cn')
|
|
13
10
|
|
|
11
|
+
// const i18nStore = await i18n.init()
|
|
12
|
+
|
|
14
13
|
function App() {
|
|
15
14
|
return (
|
|
15
|
+
// <I18nProvider store={i18nStore}>
|
|
16
16
|
<Suspense fallback={<PageLoading />}>
|
|
17
|
-
<ConfigProvider
|
|
17
|
+
<ConfigProvider>
|
|
18
18
|
<RouterProvider router={router} />
|
|
19
19
|
</ConfigProvider>
|
|
20
20
|
</Suspense>
|
|
21
|
+
// </I18nProvider>
|
|
21
22
|
)
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRoot } from
|
|
2
|
-
import
|
|
3
|
-
import App from
|
|
1
|
+
import { createRoot } from 'react-dom/client'
|
|
2
|
+
import './styles/index.css'
|
|
3
|
+
import App from './App.tsx'
|
|
4
4
|
|
|
5
|
-
createRoot(document.getElementById(
|
|
5
|
+
createRoot(document.getElementById('root')!).render(<App />)
|
|
@@ -1,15 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createJsonStorage, i18n } from '@bubblesjs/i18n-core'
|
|
2
|
+
import I18nProvider, { useI18n } from '@bubblesjs/i18n-react'
|
|
3
|
+
import { Button } from 'antd'
|
|
2
4
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const leftStore = await i18n.init({
|
|
6
|
+
locale: 'zh_CN',
|
|
7
|
+
loaderMessage: async (locale?: string) => (await import(`@/locales/${locale}.json`))?.default,
|
|
8
|
+
storageKey: 'i18n-home-left',
|
|
9
|
+
storage: createJsonStorage(localStorage),
|
|
10
|
+
})
|
|
6
11
|
|
|
7
|
-
const
|
|
8
|
-
|
|
12
|
+
const rightStore = await i18n.init({
|
|
13
|
+
locale: 'en_US',
|
|
14
|
+
loaderMessage: async (locale?: string) => (await import(`@/locales/${locale}.json`))?.default,
|
|
15
|
+
storageKey: 'i18n-home-right',
|
|
16
|
+
storage: createJsonStorage(localStorage),
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const I18nTestNode = ({ title, switchLocale }: { title: string; switchLocale: string }) => {
|
|
20
|
+
const { tr, loadLocale, locale } = useI18n()
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<section className="flex min-w-64 flex-col gap-3 rounded border border-gray-200 p-4">
|
|
24
|
+
<h2 className="text-lg font-medium">{title}</h2>
|
|
25
|
+
<div>{tr('保存')}</div>
|
|
26
|
+
<div>{tr('你好1')}</div>
|
|
27
|
+
<div>目前语言: {locale}</div>
|
|
28
|
+
<Button onClick={() => void loadLocale(switchLocale)}>切换到 {switchLocale}</Button>
|
|
29
|
+
</section>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
9
32
|
|
|
33
|
+
const Home = () => {
|
|
10
34
|
return (
|
|
11
|
-
<div className="w-full bg-
|
|
12
|
-
<
|
|
35
|
+
<div className="flex min-h-screen w-full items-center justify-center gap-6 bg-white p-6">
|
|
36
|
+
<I18nProvider store={leftStore}>
|
|
37
|
+
<I18nTestNode title="节点 A" switchLocale="en_US" />
|
|
38
|
+
</I18nProvider>
|
|
39
|
+
|
|
40
|
+
<I18nProvider store={rightStore}>
|
|
41
|
+
<I18nTestNode title="节点 B" switchLocale="zh_CN" />
|
|
42
|
+
</I18nProvider>
|
|
13
43
|
</div>
|
|
14
44
|
)
|
|
15
45
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { createBrowserRouter, Navigate, type RouteObject } from
|
|
1
|
+
import { createBrowserRouter, Navigate, type RouteObject } from 'react-router'
|
|
2
2
|
|
|
3
|
-
export const lazyLoad = (path: string, fileName =
|
|
4
|
-
const Module = lazy(() => import(`@/pages/${path}/${fileName}.tsx`))
|
|
5
|
-
return <Module
|
|
6
|
-
}
|
|
3
|
+
export const lazyLoad = (path: string, fileName = 'index') => {
|
|
4
|
+
const Module = lazy(() => import(`@/pages/${path}/${fileName}.tsx`))
|
|
5
|
+
return <Module />
|
|
6
|
+
}
|
|
7
7
|
|
|
8
8
|
const routes: RouteObject[] = [
|
|
9
9
|
{
|
|
10
|
-
path:
|
|
11
|
-
id:
|
|
12
|
-
element: <Navigate to={
|
|
10
|
+
path: '/',
|
|
11
|
+
id: 'index',
|
|
12
|
+
element: <Navigate to={'/home'} />,
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
path:
|
|
16
|
-
id:
|
|
17
|
-
element: lazyLoad(
|
|
15
|
+
path: '/home',
|
|
16
|
+
id: 'home',
|
|
17
|
+
element: lazyLoad('home'),
|
|
18
18
|
},
|
|
19
|
-
]
|
|
19
|
+
]
|
|
20
20
|
|
|
21
21
|
export const router = createBrowserRouter(routes, {
|
|
22
|
-
basename:
|
|
23
|
-
})
|
|
22
|
+
basename: '/',
|
|
23
|
+
})
|
|
24
24
|
|
|
25
|
-
export const navigator = router.navigate
|
|
25
|
+
export const navigator = router.navigate
|