specialist-agent 2.13.0 → 3.2.0
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/LICENSE +1 -1
- package/README.md +33 -207
- package/dist/catalog.json +15529 -0
- package/dist/hw-worker.mjs +254 -0
- package/dist/icones/icone.ico +0 -0
- package/dist/icones/icone.png +0 -0
- package/dist/interface/assets/figtree-latin-400-normal-g7Dtegnw.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-500-normal-BWnGEVsr.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-600-normal-Cv_xCTDl.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-700-normal-th6qEP7c.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-400-normal-CXAzuTZb.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-500-normal-Du0rIuHj.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-600-normal-DJlfifZj.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-700-normal-CS4sQkGV.woff2 +0 -0
- package/dist/interface/assets/index-BIyqZkro.css +1 -0
- package/dist/interface/assets/index-zAegy908.js +13 -0
- package/dist/interface/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-500-normal-4slEIF53.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-700-normal-CaoNriVp.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-ext-500-normal-BTIpesyw.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-ext-700-normal-BLzWLLjG.woff2 +0 -0
- package/dist/interface/icones/apple-touch-icon.png +0 -0
- package/dist/interface/icones/favicon-32.png +0 -0
- package/dist/interface/icones/icone-192.png +0 -0
- package/dist/interface/icones/icone-512.png +0 -0
- package/dist/interface/icones/icone-mascara-512.png +0 -0
- package/dist/interface/index.html +19 -0
- package/dist/interface/manifest.webmanifest +19 -0
- package/dist/interface/sw.js +63 -0
- package/dist/specialist-agent.mjs +6919 -0
- package/dist/usage-worker.mjs +174 -0
- package/package.json +32 -57
- package/.claude-plugin/marketplace.json +0 -52
- package/.claude-plugin/plugin.json +0 -37
- package/.codex/INSTALL.md +0 -145
- package/.cursor-plugin/marketplace.json +0 -52
- package/.cursor-plugin/plugin.json +0 -37
- package/.opencode/INSTALL.md +0 -127
- package/.opencode/opencode.json +0 -186
- package/agents/analyst-lite.md +0 -48
- package/agents/analyst.md +0 -396
- package/agents/api-lite.md +0 -43
- package/agents/api.md +0 -427
- package/agents/architect-lite.md +0 -104
- package/agents/architect.md +0 -571
- package/agents/autopilot-lite.md +0 -46
- package/agents/autopilot.md +0 -196
- package/agents/cloud-lite.md +0 -75
- package/agents/cloud.md +0 -213
- package/agents/data-lite.md +0 -67
- package/agents/data.md +0 -306
- package/agents/debugger-lite.md +0 -46
- package/agents/debugger.md +0 -410
- package/agents/deps-lite.md +0 -41
- package/agents/deps.md +0 -363
- package/agents/designer-lite.md +0 -67
- package/agents/designer.md +0 -195
- package/agents/devops-lite.md +0 -67
- package/agents/devops.md +0 -205
- package/agents/docs-lite.md +0 -42
- package/agents/docs.md +0 -454
- package/agents/executor-lite.md +0 -61
- package/agents/executor.md +0 -695
- package/agents/explorer-lite.md +0 -55
- package/agents/explorer.md +0 -152
- package/agents/finance-lite.md +0 -66
- package/agents/finance.md +0 -255
- package/agents/i18n-lite.md +0 -44
- package/agents/i18n.md +0 -594
- package/agents/legal-lite.md +0 -113
- package/agents/legal.md +0 -302
- package/agents/marketing-lite.md +0 -25
- package/agents/marketing.md +0 -188
- package/agents/memory.md +0 -166
- package/agents/orchestrator-lite.md +0 -40
- package/agents/orchestrator.md +0 -512
- package/agents/pair-lite.md +0 -38
- package/agents/pair.md +0 -310
- package/agents/perf-lite.md +0 -42
- package/agents/perf.md +0 -320
- package/agents/planner-lite.md +0 -59
- package/agents/planner.md +0 -272
- package/agents/product-lite.md +0 -25
- package/agents/product.md +0 -195
- package/agents/refactor-lite.md +0 -42
- package/agents/refactor.md +0 -467
- package/agents/ripple-lite.md +0 -106
- package/agents/ripple.md +0 -166
- package/agents/scout-lite.md +0 -37
- package/agents/scout.md +0 -224
- package/agents/security-lite.md +0 -66
- package/agents/security.md +0 -252
- package/agents/sentry-triage-lite.md +0 -54
- package/agents/sentry-triage.md +0 -217
- package/agents/starter-lite.md +0 -80
- package/agents/starter.md +0 -300
- package/agents/support-lite.md +0 -24
- package/agents/support.md +0 -191
- package/agents/tdd-lite.md +0 -43
- package/agents/tdd.md +0 -329
- package/agents/tester-lite.md +0 -71
- package/agents/tester.md +0 -237
- package/cli/architectures.mjs +0 -713
- package/cli/detect-architecture.mjs +0 -752
- package/cli/generate-architecture.mjs +0 -1096
- package/cli/index.mjs +0 -1217
- package/cli/recommend-architecture.mjs +0 -870
- package/hooks/after-review.mjs +0 -130
- package/hooks/after-task.mjs +0 -117
- package/hooks/before-plan.mjs +0 -155
- package/hooks/before-review.mjs +0 -139
- package/hooks/hooks.json +0 -66
- package/hooks/lifecycle.json +0 -91
- package/hooks/native/auto-dispatch.mjs +0 -207
- package/hooks/native/auto-format.mjs +0 -176
- package/hooks/native/mcp-discovery.mjs +0 -168
- package/hooks/native/security-config.json +0 -38
- package/hooks/native/security-guard.mjs +0 -323
- package/hooks/native/session-context.mjs +0 -179
- package/hooks/native/session-end.mjs +0 -42
- package/hooks/native/utils.mjs +0 -62
- package/hooks/on-error.mjs +0 -129
- package/hooks/session-end.mjs +0 -185
- package/hooks/session-start.mjs +0 -154
- package/packs/angular/ARCHITECTURE.md +0 -814
- package/packs/angular/CLAUDE.md +0 -105
- package/packs/angular/agents/builder.md +0 -113
- package/packs/angular/agents/doctor.md +0 -187
- package/packs/angular/agents/migrator.md +0 -101
- package/packs/angular/agents/reviewer.md +0 -252
- package/packs/angular/agents-lite/builder.md +0 -65
- package/packs/angular/agents-lite/doctor.md +0 -64
- package/packs/angular/agents-lite/migrator.md +0 -75
- package/packs/angular/agents-lite/reviewer.md +0 -69
- package/packs/angular/skills/dev-create-component/SKILL.md +0 -56
- package/packs/angular/skills/dev-create-injectable/SKILL.md +0 -60
- package/packs/angular/skills/dev-create-module/SKILL.md +0 -49
- package/packs/angular/skills/dev-create-service/SKILL.md +0 -34
- package/packs/angular/skills/dev-create-test/SKILL.md +0 -78
- package/packs/angular/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/angular/skills/docs-onboard/SKILL.md +0 -42
- package/packs/angular/skills/migration-migrate-component/SKILL.md +0 -42
- package/packs/angular/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/angular/skills/review-check-architecture/SKILL.md +0 -67
- package/packs/angular/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/angular/skills/review-review/SKILL.md +0 -43
- package/packs/astro/ARCHITECTURE.md +0 -718
- package/packs/astro/CLAUDE.md +0 -106
- package/packs/astro/agents/builder.md +0 -123
- package/packs/astro/agents/doctor.md +0 -200
- package/packs/astro/agents/migrator.md +0 -105
- package/packs/astro/agents/reviewer.md +0 -253
- package/packs/astro/agents-lite/builder.md +0 -71
- package/packs/astro/agents-lite/doctor.md +0 -66
- package/packs/astro/agents-lite/migrator.md +0 -71
- package/packs/astro/agents-lite/reviewer.md +0 -70
- package/packs/astro/skills/dev-create-component/SKILL.md +0 -50
- package/packs/astro/skills/dev-create-island/SKILL.md +0 -63
- package/packs/astro/skills/dev-create-module/SKILL.md +0 -49
- package/packs/astro/skills/dev-create-service/SKILL.md +0 -34
- package/packs/astro/skills/dev-create-test/SKILL.md +0 -76
- package/packs/astro/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/astro/skills/docs-onboard/SKILL.md +0 -51
- package/packs/astro/skills/migration-migrate-component/SKILL.md +0 -48
- package/packs/astro/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/astro/skills/review-check-architecture/SKILL.md +0 -72
- package/packs/astro/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/astro/skills/review-review/SKILL.md +0 -45
- package/packs/nextjs/ARCHITECTURE.md +0 -1033
- package/packs/nextjs/CLAUDE.md +0 -106
- package/packs/nextjs/agents/builder.md +0 -132
- package/packs/nextjs/agents/doctor.md +0 -226
- package/packs/nextjs/agents/migrator.md +0 -101
- package/packs/nextjs/agents/reviewer.md +0 -243
- package/packs/nextjs/agents-lite/builder.md +0 -74
- package/packs/nextjs/agents-lite/doctor.md +0 -74
- package/packs/nextjs/agents-lite/migrator.md +0 -75
- package/packs/nextjs/agents-lite/reviewer.md +0 -73
- package/packs/nextjs/skills/dev-create-component/SKILL.md +0 -82
- package/packs/nextjs/skills/dev-create-hook/SKILL.md +0 -90
- package/packs/nextjs/skills/dev-create-module/SKILL.md +0 -63
- package/packs/nextjs/skills/dev-create-service/SKILL.md +0 -35
- package/packs/nextjs/skills/dev-create-test/SKILL.md +0 -106
- package/packs/nextjs/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/nextjs/skills/docs-onboard/SKILL.md +0 -55
- package/packs/nextjs/skills/migration-migrate-component/SKILL.md +0 -58
- package/packs/nextjs/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/nextjs/skills/review-check-architecture/SKILL.md +0 -101
- package/packs/nextjs/skills/review-fix-violations/SKILL.md +0 -48
- package/packs/nextjs/skills/review-review/SKILL.md +0 -47
- package/packs/nuxt/ARCHITECTURE.md +0 -831
- package/packs/nuxt/CLAUDE.md +0 -111
- package/packs/nuxt/agents/builder.md +0 -120
- package/packs/nuxt/agents/doctor.md +0 -198
- package/packs/nuxt/agents/migrator.md +0 -101
- package/packs/nuxt/agents/reviewer.md +0 -255
- package/packs/nuxt/agents-lite/builder.md +0 -67
- package/packs/nuxt/agents-lite/doctor.md +0 -67
- package/packs/nuxt/agents-lite/migrator.md +0 -80
- package/packs/nuxt/agents-lite/reviewer.md +0 -71
- package/packs/nuxt/skills/dev-create-component/SKILL.md +0 -60
- package/packs/nuxt/skills/dev-create-composable/SKILL.md +0 -33
- package/packs/nuxt/skills/dev-create-module/SKILL.md +0 -49
- package/packs/nuxt/skills/dev-create-service/SKILL.md +0 -34
- package/packs/nuxt/skills/dev-create-test/SKILL.md +0 -61
- package/packs/nuxt/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/nuxt/skills/docs-onboard/SKILL.md +0 -49
- package/packs/nuxt/skills/migration-migrate-component/SKILL.md +0 -48
- package/packs/nuxt/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/nuxt/skills/review-check-architecture/SKILL.md +0 -71
- package/packs/nuxt/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/nuxt/skills/review-review/SKILL.md +0 -45
- package/packs/react/ARCHITECTURE.md +0 -991
- package/packs/react/CLAUDE.md +0 -102
- package/packs/react/agents/builder.md +0 -113
- package/packs/react/agents/doctor.md +0 -203
- package/packs/react/agents/migrator.md +0 -101
- package/packs/react/agents/reviewer.md +0 -252
- package/packs/react/agents-lite/builder.md +0 -65
- package/packs/react/agents-lite/doctor.md +0 -64
- package/packs/react/agents-lite/migrator.md +0 -74
- package/packs/react/agents-lite/reviewer.md +0 -69
- package/packs/react/skills/dev-create-component/SKILL.md +0 -53
- package/packs/react/skills/dev-create-hook/SKILL.md +0 -78
- package/packs/react/skills/dev-create-module/SKILL.md +0 -51
- package/packs/react/skills/dev-create-service/SKILL.md +0 -34
- package/packs/react/skills/dev-create-test/SKILL.md +0 -92
- package/packs/react/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/react/skills/docs-onboard/SKILL.md +0 -42
- package/packs/react/skills/migration-migrate-component/SKILL.md +0 -44
- package/packs/react/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/react/skills/review-check-architecture/SKILL.md +0 -73
- package/packs/react/skills/review-fix-violations/SKILL.md +0 -45
- package/packs/react/skills/review-review/SKILL.md +0 -44
- package/packs/svelte/ARCHITECTURE.md +0 -975
- package/packs/svelte/CLAUDE.md +0 -102
- package/packs/svelte/agents/builder.md +0 -114
- package/packs/svelte/agents/doctor.md +0 -174
- package/packs/svelte/agents/migrator.md +0 -101
- package/packs/svelte/agents/reviewer.md +0 -238
- package/packs/svelte/agents-lite/builder.md +0 -66
- package/packs/svelte/agents-lite/doctor.md +0 -67
- package/packs/svelte/agents-lite/migrator.md +0 -82
- package/packs/svelte/agents-lite/reviewer.md +0 -70
- package/packs/svelte/skills/dev-create-component/SKILL.md +0 -77
- package/packs/svelte/skills/dev-create-module/SKILL.md +0 -59
- package/packs/svelte/skills/dev-create-service/SKILL.md +0 -35
- package/packs/svelte/skills/dev-create-store/SKILL.md +0 -94
- package/packs/svelte/skills/dev-create-test/SKILL.md +0 -98
- package/packs/svelte/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/svelte/skills/docs-onboard/SKILL.md +0 -47
- package/packs/svelte/skills/migration-migrate-component/SKILL.md +0 -51
- package/packs/svelte/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/svelte/skills/review-check-architecture/SKILL.md +0 -79
- package/packs/svelte/skills/review-fix-violations/SKILL.md +0 -47
- package/packs/svelte/skills/review-review/SKILL.md +0 -45
- package/packs/vue/ARCHITECTURE.md +0 -798
- package/packs/vue/CLAUDE.md +0 -102
- package/packs/vue/agents/builder.md +0 -112
- package/packs/vue/agents/doctor.md +0 -185
- package/packs/vue/agents/migrator.md +0 -101
- package/packs/vue/agents/reviewer.md +0 -249
- package/packs/vue/agents-lite/builder.md +0 -65
- package/packs/vue/agents-lite/doctor.md +0 -63
- package/packs/vue/agents-lite/migrator.md +0 -73
- package/packs/vue/agents-lite/reviewer.md +0 -68
- package/packs/vue/skills/dev-create-component/SKILL.md +0 -58
- package/packs/vue/skills/dev-create-composable/SKILL.md +0 -31
- package/packs/vue/skills/dev-create-module/SKILL.md +0 -50
- package/packs/vue/skills/dev-create-service/SKILL.md +0 -34
- package/packs/vue/skills/dev-create-test/SKILL.md +0 -62
- package/packs/vue/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/vue/skills/docs-onboard/SKILL.md +0 -42
- package/packs/vue/skills/migration-migrate-component/SKILL.md +0 -41
- package/packs/vue/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/vue/skills/review-check-architecture/SKILL.md +0 -73
- package/packs/vue/skills/review-fix-violations/SKILL.md +0 -42
- package/packs/vue/skills/review-review/SKILL.md +0 -43
- package/skills/audit/SKILL.md +0 -231
- package/skills/autofix/SKILL.md +0 -166
- package/skills/autopilot/SKILL.md +0 -286
- package/skills/brainstorm/SKILL.md +0 -298
- package/skills/checkpoint/SKILL.md +0 -217
- package/skills/codereview/SKILL.md +0 -268
- package/skills/commit/SKILL.md +0 -150
- package/skills/copywriting/SKILL.md +0 -218
- package/skills/cro/SKILL.md +0 -234
- package/skills/debug/SKILL.md +0 -210
- package/skills/design-review/SKILL.md +0 -217
- package/skills/discovery/SKILL.md +0 -218
- package/skills/estimate/SKILL.md +0 -154
- package/skills/finish/SKILL.md +0 -220
- package/skills/grill/SKILL.md +0 -270
- package/skills/health/SKILL.md +0 -251
- package/skills/improve-architecture/SKILL.md +0 -205
- package/skills/learn/SKILL.md +0 -260
- package/skills/lint/SKILL.md +0 -126
- package/skills/migrate-architecture/SKILL.md +0 -242
- package/skills/migrate-framework/SKILL.md +0 -172
- package/skills/onboard/SKILL.md +0 -168
- package/skills/plan/SKILL.md +0 -141
- package/skills/prd/SKILL.md +0 -241
- package/skills/recall/SKILL.md +0 -112
- package/skills/remember/SKILL.md +0 -108
- package/skills/seo-audit/SKILL.md +0 -240
- package/skills/tdd/SKILL.md +0 -201
- package/skills/tutorial/SKILL.md +0 -346
- package/skills/verify/SKILL.md +0 -168
- package/skills/worktree/SKILL.md +0 -168
- package/skills/write-skill/SKILL.md +0 -225
- package/templates/autopilot/PROMPT.md +0 -39
- package/templates/autopilot/README.md +0 -122
- package/templates/autopilot/devcontainer.json +0 -21
- package/templates/industry/ecommerce.md +0 -127
- package/templates/industry/fintech.md +0 -161
- package/templates/industry/saas.md +0 -134
- package/templates/session-memory.json +0 -48
- package/templates/skill-template/SKILL.md +0 -90
|
@@ -1,831 +0,0 @@
|
|
|
1
|
-
# ARCHITECTURE.md - Architecture Guide and Patterns
|
|
2
|
-
|
|
3
|
-
> This document is the **source of truth** for all agents and skills.
|
|
4
|
-
> Any architectural decision must be documented here.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## 1. Overview
|
|
9
|
-
|
|
10
|
-
Nuxt 3 is a full-stack Vue 3 framework with auto-imports, file-based routing, and a built-in Nitro server engine. This architecture leverages Nuxt's conventions for a modern, typed, and modular codebase:
|
|
11
|
-
|
|
12
|
-
| Feature | Approach |
|
|
13
|
-
|---------|----------|
|
|
14
|
-
| Language | TypeScript (strict) |
|
|
15
|
-
| Components | `<script setup lang="ts">` with auto-imports |
|
|
16
|
-
| Server state | `useFetch` / `useAsyncData` (built-in caching) |
|
|
17
|
-
| Client state (simple) | `useState` (SSR-safe) |
|
|
18
|
-
| Client state (complex) | Pinia (setup syntax) |
|
|
19
|
-
| Routing | File-based (`pages/` directory) |
|
|
20
|
-
| Server API | Nitro (`server/api/` directory) |
|
|
21
|
-
| Rendering | Hybrid (SSR, SSG, SPA per route) |
|
|
22
|
-
| Validation | Zod schemas |
|
|
23
|
-
| Testing | Vitest + `@nuxt/test-utils` |
|
|
24
|
-
| Naming | kebab-case files, PascalCase components |
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## 2. Directory Structure (Modular Architecture)
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
├── app/ # App shell
|
|
32
|
-
│ ├── app.vue # Root component
|
|
33
|
-
│ └── error.vue # Global error page
|
|
34
|
-
│
|
|
35
|
-
├── pages/ # File-based routing
|
|
36
|
-
│ ├── index.vue # /
|
|
37
|
-
│ ├── login.vue # /login
|
|
38
|
-
│ └── marketplace/
|
|
39
|
-
│ ├── index.vue # /marketplace
|
|
40
|
-
│ └── [id].vue # /marketplace/:id
|
|
41
|
-
│
|
|
42
|
-
├── layouts/ # Layout components
|
|
43
|
-
│ ├── default.vue
|
|
44
|
-
│ └── auth.vue
|
|
45
|
-
│
|
|
46
|
-
├── components/ # Auto-imported shared components
|
|
47
|
-
│ ├── AppButton.vue
|
|
48
|
-
│ ├── AppModal.vue
|
|
49
|
-
│ └── AppTable.vue
|
|
50
|
-
│
|
|
51
|
-
├── composables/ # Auto-imported shared composables
|
|
52
|
-
│ ├── useAuth.ts
|
|
53
|
-
│ └── useToast.ts
|
|
54
|
-
│
|
|
55
|
-
├── modules/ # Feature modules (bounded contexts)
|
|
56
|
-
│ └── marketplace/
|
|
57
|
-
│ ├── components/
|
|
58
|
-
│ │ ├── MarketplaceList.vue
|
|
59
|
-
│ │ ├── MarketplaceCard.vue
|
|
60
|
-
│ │ └── MarketplaceFilters.vue
|
|
61
|
-
│ ├── composables/
|
|
62
|
-
│ │ ├── useMarketplaceList.ts
|
|
63
|
-
│ │ └── useMarketplaceFilters.ts
|
|
64
|
-
│ ├── services/
|
|
65
|
-
│ │ └── marketplace-service.ts
|
|
66
|
-
│ ├── adapters/
|
|
67
|
-
│ │ └── marketplace-adapter.ts
|
|
68
|
-
│ ├── types/
|
|
69
|
-
│ │ ├── marketplace.types.ts
|
|
70
|
-
│ │ └── marketplace.contracts.ts
|
|
71
|
-
│ ├── __tests__/
|
|
72
|
-
│ └── index.ts # Barrel export (public API)
|
|
73
|
-
│
|
|
74
|
-
├── server/ # Nitro server engine
|
|
75
|
-
│ ├── api/ # API routes
|
|
76
|
-
│ │ ├── marketplace/
|
|
77
|
-
│ │ │ ├── index.get.ts # GET /api/marketplace
|
|
78
|
-
│ │ │ ├── index.post.ts # POST /api/marketplace
|
|
79
|
-
│ │ │ └── [id].get.ts # GET /api/marketplace/:id
|
|
80
|
-
│ │ └── auth/
|
|
81
|
-
│ │ └── login.post.ts
|
|
82
|
-
│ ├── middleware/ # Server middleware
|
|
83
|
-
│ │ └── auth.ts
|
|
84
|
-
│ └── utils/ # Server-side utilities
|
|
85
|
-
│ ├── db.ts
|
|
86
|
-
│ └── validate.ts
|
|
87
|
-
│
|
|
88
|
-
├── middleware/ # Route middleware (client-side)
|
|
89
|
-
│ ├── auth.ts
|
|
90
|
-
│ └── guest.ts
|
|
91
|
-
│
|
|
92
|
-
├── plugins/ # Nuxt plugins (app initialization)
|
|
93
|
-
│ └── error-handler.ts
|
|
94
|
-
│
|
|
95
|
-
├── shared/ # Shared utilities
|
|
96
|
-
│ ├── utils/ # Pure functions
|
|
97
|
-
│ ├── helpers/ # Functions with side effects
|
|
98
|
-
│ ├── types/ # Global types
|
|
99
|
-
│ └── constants/ # Static values
|
|
100
|
-
│
|
|
101
|
-
├── assets/ # Static assets (processed by Vite)
|
|
102
|
-
│
|
|
103
|
-
└── public/ # Public static files (served as-is)
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Import Rules Between Layers
|
|
107
|
-
```
|
|
108
|
-
modules/auth <-> shared/ OK - Module imports from shared
|
|
109
|
-
modules/auth -> modules/market PROHIBITED - Module imports from another module
|
|
110
|
-
shared/ -> modules/auth PROHIBITED - Shared imports from module
|
|
111
|
-
pages/ -> modules/* OK - Pages import module components/composables
|
|
112
|
-
composables/ <-> shared/ OK - Shared composables use shared utils
|
|
113
|
-
server/ -> shared/types OK - Server uses shared types
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
If two modules need to share something, move it to `shared/` or `composables/`.
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## 3. Naming Conventions
|
|
121
|
-
|
|
122
|
-
### Files and Directories
|
|
123
|
-
|
|
124
|
-
| Type | Pattern | Example |
|
|
125
|
-
|------|---------|---------|
|
|
126
|
-
| Directories | `kebab-case` | `user-settings/` |
|
|
127
|
-
| Vue Components | `PascalCase.vue` | `MarketplaceCard.vue` |
|
|
128
|
-
| Pages | `kebab-case.vue` | `marketplace/index.vue` |
|
|
129
|
-
| Composables | `use` + `PascalCase.ts` | `useMarketplaceList.ts` |
|
|
130
|
-
| Services | `kebab-case-service.ts` | `marketplace-service.ts` |
|
|
131
|
-
| Adapters | `kebab-case-adapter.ts` | `marketplace-adapter.ts` |
|
|
132
|
-
| Server API routes | `kebab-case.[method].ts` | `index.get.ts`, `[id].delete.ts` |
|
|
133
|
-
| Types | `kebab-case.types.ts` | `marketplace.types.ts` |
|
|
134
|
-
| Contracts/Schemas | `kebab-case.contracts.ts` | `marketplace.contracts.ts` |
|
|
135
|
-
| Utils | `kebab-case.ts` | `format-date.ts` |
|
|
136
|
-
| Helpers | `kebab-case.ts` | `clipboard-helper.ts` |
|
|
137
|
-
| Tests | `OriginalName.spec.ts` | `MarketplaceList.spec.ts` |
|
|
138
|
-
| Middleware | `kebab-case.ts` | `auth.ts` |
|
|
139
|
-
| Plugins | `kebab-case.ts` | `error-handler.ts` |
|
|
140
|
-
|
|
141
|
-
### Code
|
|
142
|
-
|
|
143
|
-
| Type | Pattern | Example |
|
|
144
|
-
|------|---------|---------|
|
|
145
|
-
| Variables / functions | `camelCase` | `getUserById`, `isLoading` |
|
|
146
|
-
| Types / Interfaces | `PascalCase` | `UserProfile`, `MarketplaceItem` |
|
|
147
|
-
| Enums | `PascalCase` | `UserRole.Admin` |
|
|
148
|
-
| Constants | `UPPER_SNAKE_CASE` | `API_BASE_URL`, `MAX_RETRIES` |
|
|
149
|
-
| Composables | `use` + `PascalCase` | `useAuth`, `useMarketplaceList` |
|
|
150
|
-
| Event handlers | `handle` + action | `handleSubmit`, `handleDelete` |
|
|
151
|
-
| Boolean | `is`/`has`/`can`/`should` | `isLoading`, `hasPermission` |
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## 4. Responsibility Layers
|
|
156
|
-
|
|
157
|
-
### 4.1 Services - Pure HTTP Requests
|
|
158
|
-
|
|
159
|
-
Services perform **only** the HTTP request. No try/catch, no transformation, no business logic.
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
// modules/marketplace/services/marketplace-service.ts
|
|
163
|
-
import type { MarketplaceListResponse, MarketplaceItemResponse } from '../types/marketplace.types'
|
|
164
|
-
|
|
165
|
-
export const marketplaceService = {
|
|
166
|
-
list(params: { page: number; pageSize: number; search?: string }) {
|
|
167
|
-
return $fetch<MarketplaceListResponse>('/api/marketplace', { params })
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
getById(id: string) {
|
|
171
|
-
return $fetch<MarketplaceItemResponse>(`/api/marketplace/${id}`)
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
create(payload: CreateMarketplacePayload) {
|
|
175
|
-
return $fetch<MarketplaceItemResponse>('/api/marketplace', {
|
|
176
|
-
method: 'POST',
|
|
177
|
-
body: payload,
|
|
178
|
-
})
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
delete(id: string) {
|
|
182
|
-
return $fetch(`/api/marketplace/${id}`, { method: 'DELETE' })
|
|
183
|
-
},
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
**Service rules:**
|
|
188
|
-
- NO try/catch (caller handles errors)
|
|
189
|
-
- NO data transformation (adapter does that)
|
|
190
|
-
- NO business logic
|
|
191
|
-
- NO access to stores or composables
|
|
192
|
-
- YES typed request/response
|
|
193
|
-
- YES one file per domain/resource
|
|
194
|
-
- YES export as object with methods
|
|
195
|
-
- Use `$fetch` (Nuxt built-in) instead of axios
|
|
196
|
-
|
|
197
|
-
### 4.2 Adapters - Contract Parsers
|
|
198
|
-
|
|
199
|
-
Adapters transform data from the API to the TypeScript app contract (and vice-versa). They are **pure functions** without side effects.
|
|
200
|
-
|
|
201
|
-
```typescript
|
|
202
|
-
// modules/marketplace/adapters/marketplace-adapter.ts
|
|
203
|
-
import type {
|
|
204
|
-
MarketplaceListResponse,
|
|
205
|
-
MarketplaceItemResponse,
|
|
206
|
-
} from '../types/marketplace.types'
|
|
207
|
-
import type {
|
|
208
|
-
MarketplaceItem,
|
|
209
|
-
MarketplaceList,
|
|
210
|
-
} from '../types/marketplace.contracts'
|
|
211
|
-
|
|
212
|
-
export const marketplaceAdapter = {
|
|
213
|
-
toMarketplaceItem(response: MarketplaceItemResponse): MarketplaceItem {
|
|
214
|
-
return {
|
|
215
|
-
id: response.uuid,
|
|
216
|
-
name: response.name,
|
|
217
|
-
vendor: response.vendor_name,
|
|
218
|
-
category: response.category_slug,
|
|
219
|
-
price: response.price_cents / 100,
|
|
220
|
-
isActive: response.status === 'active',
|
|
221
|
-
createdAt: new Date(response.created_at),
|
|
222
|
-
updatedAt: new Date(response.updated_at),
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
toMarketplaceList(response: MarketplaceListResponse): MarketplaceList {
|
|
227
|
-
return {
|
|
228
|
-
items: response.results.map(marketplaceAdapter.toMarketplaceItem),
|
|
229
|
-
totalItems: response.count,
|
|
230
|
-
totalPages: Math.ceil(response.count / response.page_size),
|
|
231
|
-
currentPage: response.page,
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
toCreatePayload(item: CreateMarketplaceInput): CreateMarketplacePayload {
|
|
236
|
-
return {
|
|
237
|
-
name: item.name,
|
|
238
|
-
vendor_name: item.vendor,
|
|
239
|
-
category_slug: item.category,
|
|
240
|
-
price_cents: Math.round(item.price * 100),
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
}
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
**Adapter rules:**
|
|
247
|
-
- Pure functions (input -> output, no side effects)
|
|
248
|
-
- Two directions: API->App (inbound) and App->API (outbound)
|
|
249
|
-
- Rename fields (snake_case API -> camelCase App)
|
|
250
|
-
- Convert types (string->Date, cents->decimal, status->boolean)
|
|
251
|
-
- NO HTTP calls
|
|
252
|
-
- NO access to store/composable
|
|
253
|
-
- NO try/catch (failure = wrong type = bug to fix)
|
|
254
|
-
|
|
255
|
-
### 4.3 Types & Contracts
|
|
256
|
-
|
|
257
|
-
```typescript
|
|
258
|
-
// types/marketplace.types.ts
|
|
259
|
-
// Types that mirror the API exactly as it returns (snake_case)
|
|
260
|
-
|
|
261
|
-
export interface MarketplaceItemResponse {
|
|
262
|
-
uuid: string
|
|
263
|
-
name: string
|
|
264
|
-
vendor_name: string
|
|
265
|
-
category_slug: string
|
|
266
|
-
price_cents: number
|
|
267
|
-
status: 'active' | 'inactive' | 'pending'
|
|
268
|
-
created_at: string
|
|
269
|
-
updated_at: string
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export interface MarketplaceListResponse {
|
|
273
|
-
count: number
|
|
274
|
-
page: number
|
|
275
|
-
page_size: number
|
|
276
|
-
results: MarketplaceItemResponse[]
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// types/marketplace.contracts.ts
|
|
280
|
-
// App contracts (camelCase, correct types)
|
|
281
|
-
|
|
282
|
-
export interface MarketplaceItem {
|
|
283
|
-
id: string
|
|
284
|
-
name: string
|
|
285
|
-
vendor: string
|
|
286
|
-
category: string
|
|
287
|
-
price: number // in currency units, not cents
|
|
288
|
-
isActive: boolean // derived from status
|
|
289
|
-
createdAt: Date
|
|
290
|
-
updatedAt: Date
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export interface MarketplaceList {
|
|
294
|
-
items: MarketplaceItem[]
|
|
295
|
-
totalItems: number
|
|
296
|
-
totalPages: number
|
|
297
|
-
currentPage: number
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export interface CreateMarketplaceInput {
|
|
301
|
-
name: string
|
|
302
|
-
vendor: string
|
|
303
|
-
category: string
|
|
304
|
-
price: number
|
|
305
|
-
}
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
### 4.4 Composables - Business Logic + Orchestration
|
|
309
|
-
|
|
310
|
-
Composables connect everything: call service, pass through adapter, manage loading/error, and expose reactive data. In Nuxt, composables in the `composables/` directory are **auto-imported**.
|
|
311
|
-
|
|
312
|
-
```typescript
|
|
313
|
-
// modules/marketplace/composables/useMarketplaceList.ts
|
|
314
|
-
import { marketplaceService } from '../services/marketplace-service'
|
|
315
|
-
import { marketplaceAdapter } from '../adapters/marketplace-adapter'
|
|
316
|
-
import type { MarketplaceList } from '../types/marketplace.contracts'
|
|
317
|
-
|
|
318
|
-
interface UseMarketplaceListOptions {
|
|
319
|
-
page: Ref<number>
|
|
320
|
-
pageSize?: Ref<number>
|
|
321
|
-
search?: Ref<string>
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export function useMarketplaceList(options: UseMarketplaceListOptions) {
|
|
325
|
-
const page = computed(() => toValue(options.page))
|
|
326
|
-
const pageSize = computed(() => toValue(options.pageSize) ?? 20)
|
|
327
|
-
const search = computed(() => toValue(options.search) ?? '')
|
|
328
|
-
|
|
329
|
-
const { data, status, error, refresh } = useAsyncData(
|
|
330
|
-
() => `marketplace-list-${page.value}-${pageSize.value}-${search.value}`,
|
|
331
|
-
() => marketplaceService.list({
|
|
332
|
-
page: page.value,
|
|
333
|
-
pageSize: pageSize.value,
|
|
334
|
-
search: search.value,
|
|
335
|
-
}),
|
|
336
|
-
{
|
|
337
|
-
transform: (response) => marketplaceAdapter.toMarketplaceList(response),
|
|
338
|
-
watch: [page, pageSize, search],
|
|
339
|
-
},
|
|
340
|
-
)
|
|
341
|
-
|
|
342
|
-
const items = computed(() => data.value?.items ?? [])
|
|
343
|
-
const totalPages = computed(() => data.value?.totalPages ?? 0)
|
|
344
|
-
const isLoading = computed(() => status.value === 'pending')
|
|
345
|
-
const isEmpty = computed(() => !isLoading.value && items.value.length === 0)
|
|
346
|
-
|
|
347
|
-
return {
|
|
348
|
-
// Data
|
|
349
|
-
items,
|
|
350
|
-
totalPages,
|
|
351
|
-
// State
|
|
352
|
-
isLoading,
|
|
353
|
-
isEmpty,
|
|
354
|
-
error,
|
|
355
|
-
// Actions
|
|
356
|
-
refresh,
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
**Composable rules:**
|
|
362
|
-
- Orchestrate: service -> adapter -> reactive data
|
|
363
|
-
- Manage loading, error, empty states
|
|
364
|
-
- Return refs/computed (never raw values)
|
|
365
|
-
- Name with `use` prefix
|
|
366
|
-
- Typed return values
|
|
367
|
-
- NO template/rendering (component does that)
|
|
368
|
-
- NO direct API access (service does that)
|
|
369
|
-
- Use `useAsyncData` or `useFetch` for server state (not TanStack Query)
|
|
370
|
-
|
|
371
|
-
### 4.5 useState - SSR-Safe Shared State
|
|
372
|
-
|
|
373
|
-
`useState` is Nuxt's built-in SSR-friendly state. Use it for simple shared state that needs to survive SSR hydration.
|
|
374
|
-
|
|
375
|
-
```typescript
|
|
376
|
-
// composables/useMarketplaceFilters.ts
|
|
377
|
-
export function useMarketplaceFilters() {
|
|
378
|
-
const selectedCategory = useState<string | null>('marketplace-category', () => null)
|
|
379
|
-
const viewMode = useState<'grid' | 'list'>('marketplace-view-mode', () => 'grid')
|
|
380
|
-
const searchQuery = useState<string>('marketplace-search', () => '')
|
|
381
|
-
|
|
382
|
-
const hasActiveFilters = computed(() =>
|
|
383
|
-
!!selectedCategory.value || !!searchQuery.value
|
|
384
|
-
)
|
|
385
|
-
|
|
386
|
-
function setCategory(category: string | null) {
|
|
387
|
-
selectedCategory.value = category
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
function setViewMode(mode: 'grid' | 'list') {
|
|
391
|
-
viewMode.value = mode
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
function clearFilters() {
|
|
395
|
-
selectedCategory.value = null
|
|
396
|
-
searchQuery.value = ''
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
return {
|
|
400
|
-
selectedCategory: readonly(selectedCategory),
|
|
401
|
-
viewMode: readonly(viewMode),
|
|
402
|
-
searchQuery,
|
|
403
|
-
hasActiveFilters,
|
|
404
|
-
setCategory,
|
|
405
|
-
setViewMode,
|
|
406
|
-
clearFilters,
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
### 4.6 Pinia Stores - Complex Client State Only
|
|
412
|
-
|
|
413
|
-
Use Pinia only when `useState` is not enough (complex state, devtools, plugin ecosystem).
|
|
414
|
-
|
|
415
|
-
```typescript
|
|
416
|
-
// modules/marketplace/stores/marketplace-store.ts
|
|
417
|
-
import { defineStore } from 'pinia'
|
|
418
|
-
|
|
419
|
-
export const useMarketplaceStore = defineStore('marketplace', () => {
|
|
420
|
-
// State
|
|
421
|
-
const cart = ref<CartItem[]>([])
|
|
422
|
-
const recentlyViewed = ref<string[]>([])
|
|
423
|
-
|
|
424
|
-
// Getters
|
|
425
|
-
const cartTotal = computed(() =>
|
|
426
|
-
cart.value.reduce((sum, item) => sum + item.price * item.quantity, 0)
|
|
427
|
-
)
|
|
428
|
-
|
|
429
|
-
const cartCount = computed(() =>
|
|
430
|
-
cart.value.reduce((sum, item) => sum + item.quantity, 0)
|
|
431
|
-
)
|
|
432
|
-
|
|
433
|
-
// Actions
|
|
434
|
-
function addToCart(item: CartItem) {
|
|
435
|
-
const existing = cart.value.find(i => i.id === item.id)
|
|
436
|
-
if (existing) {
|
|
437
|
-
existing.quantity += item.quantity
|
|
438
|
-
} else {
|
|
439
|
-
cart.value.push(item)
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function removeFromCart(id: string) {
|
|
444
|
-
cart.value = cart.value.filter(i => i.id !== id)
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
return {
|
|
448
|
-
cart: readonly(cart),
|
|
449
|
-
recentlyViewed: readonly(recentlyViewed),
|
|
450
|
-
cartTotal,
|
|
451
|
-
cartCount,
|
|
452
|
-
addToCart,
|
|
453
|
-
removeFromCart,
|
|
454
|
-
}
|
|
455
|
-
})
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
**State management rules:**
|
|
459
|
-
- `useState` for simple shared state (filters, UI mode, preferences)
|
|
460
|
-
- Pinia for complex client state (cart, multi-step forms, computed chains)
|
|
461
|
-
- `useFetch` / `useAsyncData` for server state - NEVER in Pinia
|
|
462
|
-
- Pinia: setup syntax, readonly() on state, storeToRefs() in consumers
|
|
463
|
-
- NO HTTP calls inside stores
|
|
464
|
-
|
|
465
|
-
### 4.7 Server Routes (Nitro)
|
|
466
|
-
|
|
467
|
-
```typescript
|
|
468
|
-
// server/api/marketplace/index.get.ts
|
|
469
|
-
import { z } from 'zod'
|
|
470
|
-
|
|
471
|
-
const querySchema = z.object({
|
|
472
|
-
page: z.coerce.number().min(1).default(1),
|
|
473
|
-
pageSize: z.coerce.number().min(1).max(100).default(20),
|
|
474
|
-
search: z.string().optional(),
|
|
475
|
-
})
|
|
476
|
-
|
|
477
|
-
export default defineEventHandler(async (event) => {
|
|
478
|
-
const query = await getValidatedQuery(event, querySchema.parse)
|
|
479
|
-
|
|
480
|
-
// Fetch from database or external API
|
|
481
|
-
const items = await fetchMarketplaceItems(query)
|
|
482
|
-
|
|
483
|
-
return items
|
|
484
|
-
})
|
|
485
|
-
|
|
486
|
-
// server/api/marketplace/index.post.ts
|
|
487
|
-
import { z } from 'zod'
|
|
488
|
-
|
|
489
|
-
const bodySchema = z.object({
|
|
490
|
-
name: z.string().min(1).max(255),
|
|
491
|
-
vendor_name: z.string().min(1),
|
|
492
|
-
category_slug: z.string().min(1),
|
|
493
|
-
price_cents: z.number().int().positive(),
|
|
494
|
-
})
|
|
495
|
-
|
|
496
|
-
export default defineEventHandler(async (event) => {
|
|
497
|
-
const body = await readValidatedBody(event, bodySchema.parse)
|
|
498
|
-
|
|
499
|
-
const item = await createMarketplaceItem(body)
|
|
500
|
-
|
|
501
|
-
return item
|
|
502
|
-
})
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
---
|
|
506
|
-
|
|
507
|
-
## 5. Components - Composition Pattern
|
|
508
|
-
|
|
509
|
-
### 5.1 SFC Pattern (with auto-imports)
|
|
510
|
-
|
|
511
|
-
```vue
|
|
512
|
-
<script setup lang="ts">
|
|
513
|
-
// In Nuxt, composables, components, and Vue APIs are auto-imported
|
|
514
|
-
// NO import statements needed for: ref, computed, watch, useRoute, etc.
|
|
515
|
-
|
|
516
|
-
// 1. Props & Emits (type-based)
|
|
517
|
-
interface Props {
|
|
518
|
-
categoryFilter?: string
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
interface Emits {
|
|
522
|
-
(e: 'select', item: MarketplaceItem): void
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
526
|
-
categoryFilter: undefined,
|
|
527
|
-
})
|
|
528
|
-
|
|
529
|
-
const emit = defineEmits<Emits>()
|
|
530
|
-
|
|
531
|
-
// 2. Composables (auto-imported if in composables/ dir)
|
|
532
|
-
const page = ref(1)
|
|
533
|
-
const { items, totalPages, isLoading, isEmpty } = useMarketplaceList({
|
|
534
|
-
page,
|
|
535
|
-
})
|
|
536
|
-
|
|
537
|
-
// 3. Local state
|
|
538
|
-
const selectedId = ref<string | null>(null)
|
|
539
|
-
|
|
540
|
-
// 4. Computed
|
|
541
|
-
const isFirstPage = computed(() => page.value === 1)
|
|
542
|
-
|
|
543
|
-
// 5. Handlers
|
|
544
|
-
function handleSelect(item: MarketplaceItem) {
|
|
545
|
-
selectedId.value = item.id
|
|
546
|
-
emit('select', item)
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
function handlePageChange(newPage: number) {
|
|
550
|
-
page.value = newPage
|
|
551
|
-
}
|
|
552
|
-
</script>
|
|
553
|
-
|
|
554
|
-
<template>
|
|
555
|
-
<!-- ... -->
|
|
556
|
-
</template>
|
|
557
|
-
|
|
558
|
-
<style scoped>
|
|
559
|
-
/* ... */
|
|
560
|
-
</style>
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
### 5.2 Stop Prop Drilling - Component Composition
|
|
564
|
-
|
|
565
|
-
**WRONG - Prop Drilling:**
|
|
566
|
-
```vue
|
|
567
|
-
<Parent :user="user" :theme="theme" :permissions="permissions">
|
|
568
|
-
<Child :user="user" :theme="theme" :permissions="permissions">
|
|
569
|
-
<GrandChild :user="user" :permissions="permissions" />
|
|
570
|
-
</Child>
|
|
571
|
-
</Parent>
|
|
572
|
-
```
|
|
573
|
-
|
|
574
|
-
**CORRECT - Composition with Slots:**
|
|
575
|
-
```vue
|
|
576
|
-
<!-- pages/marketplace/index.vue -->
|
|
577
|
-
<template>
|
|
578
|
-
<NuxtLayout>
|
|
579
|
-
<MarketplaceFilters />
|
|
580
|
-
|
|
581
|
-
<MarketplaceList @select="handleSelect">
|
|
582
|
-
<template #card="{ item }">
|
|
583
|
-
<MarketplaceCard :item="item" />
|
|
584
|
-
</template>
|
|
585
|
-
|
|
586
|
-
<template #empty>
|
|
587
|
-
<EmptyState message="No items found" />
|
|
588
|
-
</template>
|
|
589
|
-
</MarketplaceList>
|
|
590
|
-
|
|
591
|
-
<MarketplaceDetails v-if="selectedItem" :item="selectedItem" />
|
|
592
|
-
</NuxtLayout>
|
|
593
|
-
</template>
|
|
594
|
-
```
|
|
595
|
-
|
|
596
|
-
**CORRECT - Provide/Inject for shared context:**
|
|
597
|
-
```typescript
|
|
598
|
-
// composables/useMarketplaceContext.ts
|
|
599
|
-
import type { InjectionKey, Ref } from 'vue'
|
|
600
|
-
|
|
601
|
-
interface MarketplaceContext {
|
|
602
|
-
selectedItem: Ref<MarketplaceItem | null>
|
|
603
|
-
selectItem: (item: MarketplaceItem) => void
|
|
604
|
-
clearSelection: () => void
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
export const MARKETPLACE_CONTEXT: InjectionKey<MarketplaceContext> = Symbol('marketplace-context')
|
|
608
|
-
|
|
609
|
-
export function provideMarketplaceContext() {
|
|
610
|
-
const selectedItem = ref<MarketplaceItem | null>(null)
|
|
611
|
-
|
|
612
|
-
function selectItem(item: MarketplaceItem) {
|
|
613
|
-
selectedItem.value = item
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
function clearSelection() {
|
|
617
|
-
selectedItem.value = null
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
const context: MarketplaceContext = {
|
|
621
|
-
selectedItem: readonly(selectedItem),
|
|
622
|
-
selectItem,
|
|
623
|
-
clearSelection,
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
provide(MARKETPLACE_CONTEXT, context)
|
|
627
|
-
return context
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
export function useMarketplaceContext() {
|
|
631
|
-
const context = inject(MARKETPLACE_CONTEXT)
|
|
632
|
-
if (!context) {
|
|
633
|
-
throw new Error('useMarketplaceContext must be used within a provider')
|
|
634
|
-
}
|
|
635
|
-
return context
|
|
636
|
-
}
|
|
637
|
-
```
|
|
638
|
-
|
|
639
|
-
### 5.3 Component Hierarchy
|
|
640
|
-
|
|
641
|
-
```
|
|
642
|
-
Pages (pages/) -> Composition, orchestration, provide context
|
|
643
|
-
└── Layout -> Visual structure (slots)
|
|
644
|
-
└── Features -> Feature logic (composables)
|
|
645
|
-
└── Shared -> Pure presentation (props in, events out)
|
|
646
|
-
```
|
|
647
|
-
|
|
648
|
-
| Type | Responsibility | Can have logic? | Can have state? |
|
|
649
|
-
|------|---------------|----------------|----------------|
|
|
650
|
-
| **Pages** | Compose components, provide context | Via composables | Yes (composables) |
|
|
651
|
-
| **Feature Components** | UI + feature logic | Via composables | Yes (composables) |
|
|
652
|
-
| **Shared Components** | Generic, reusable UI | Minimal (UI only) | Minimal (local) |
|
|
653
|
-
|
|
654
|
-
---
|
|
655
|
-
|
|
656
|
-
## 6. Utils vs Helpers
|
|
657
|
-
|
|
658
|
-
### Utils - Pure Functions
|
|
659
|
-
- No side effects
|
|
660
|
-
- Input -> Output deterministic
|
|
661
|
-
- Testable without mocks
|
|
662
|
-
- No dependency on DOM, browser APIs, or Vue
|
|
663
|
-
|
|
664
|
-
```typescript
|
|
665
|
-
// shared/utils/format-date.ts
|
|
666
|
-
export function formatDate(date: Date, locale = 'en-US'): string {
|
|
667
|
-
return new Intl.DateTimeFormat(locale).format(date)
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
// shared/utils/currency.ts
|
|
671
|
-
export function formatCurrency(value: number, currency = 'USD'): string {
|
|
672
|
-
return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(value)
|
|
673
|
-
}
|
|
674
|
-
```
|
|
675
|
-
|
|
676
|
-
### Helpers - Functions with Side Effects
|
|
677
|
-
- Interact with browser APIs (clipboard, localStorage, DOM)
|
|
678
|
-
- May have side effects
|
|
679
|
-
- May need mocks in tests
|
|
680
|
-
|
|
681
|
-
```typescript
|
|
682
|
-
// shared/helpers/clipboard-helper.ts
|
|
683
|
-
export async function copyToClipboard(text: string): Promise<boolean> {
|
|
684
|
-
try {
|
|
685
|
-
await navigator.clipboard.writeText(text)
|
|
686
|
-
return true
|
|
687
|
-
} catch {
|
|
688
|
-
return false
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
```
|
|
692
|
-
|
|
693
|
-
---
|
|
694
|
-
|
|
695
|
-
## 7. Error Handling - Centralized Pattern
|
|
696
|
-
|
|
697
|
-
### In Composables (useFetch / useAsyncData)
|
|
698
|
-
```typescript
|
|
699
|
-
const { data, error } = await useFetch('/api/marketplace', {
|
|
700
|
-
onResponseError({ response }) {
|
|
701
|
-
showError({
|
|
702
|
-
statusCode: response.status,
|
|
703
|
-
statusMessage: response.statusText,
|
|
704
|
-
})
|
|
705
|
-
},
|
|
706
|
-
})
|
|
707
|
-
```
|
|
708
|
-
|
|
709
|
-
### Global Error Page (error.vue)
|
|
710
|
-
```vue
|
|
711
|
-
<!-- app/error.vue -->
|
|
712
|
-
<script setup lang="ts">
|
|
713
|
-
const props = defineProps<{
|
|
714
|
-
error: {
|
|
715
|
-
statusCode: number
|
|
716
|
-
statusMessage: string
|
|
717
|
-
message: string
|
|
718
|
-
}
|
|
719
|
-
}>()
|
|
720
|
-
|
|
721
|
-
function handleClearError() {
|
|
722
|
-
clearError({ redirect: '/' })
|
|
723
|
-
}
|
|
724
|
-
</script>
|
|
725
|
-
|
|
726
|
-
<template>
|
|
727
|
-
<div>
|
|
728
|
-
<h1>{{ error.statusCode }}</h1>
|
|
729
|
-
<p>{{ error.message }}</p>
|
|
730
|
-
<button @click="handleClearError">Go home</button>
|
|
731
|
-
</div>
|
|
732
|
-
</template>
|
|
733
|
-
```
|
|
734
|
-
|
|
735
|
-
### Server Error Handling (Nitro)
|
|
736
|
-
```typescript
|
|
737
|
-
// server/api/marketplace/[id].get.ts
|
|
738
|
-
export default defineEventHandler(async (event) => {
|
|
739
|
-
const id = getRouterParam(event, 'id')
|
|
740
|
-
|
|
741
|
-
const item = await findMarketplaceItem(id)
|
|
742
|
-
if (!item) {
|
|
743
|
-
throw createError({
|
|
744
|
-
statusCode: 404,
|
|
745
|
-
statusMessage: 'Item not found',
|
|
746
|
-
})
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
return item
|
|
750
|
-
})
|
|
751
|
-
```
|
|
752
|
-
|
|
753
|
-
### Error Utilities
|
|
754
|
-
- `useError()` - access current error in components
|
|
755
|
-
- `showError()` - trigger the error page
|
|
756
|
-
- `clearError()` - clear error and optionally redirect
|
|
757
|
-
- `createError()` - create an error in server routes
|
|
758
|
-
|
|
759
|
-
---
|
|
760
|
-
|
|
761
|
-
## 8. Barrel Exports (index.ts)
|
|
762
|
-
|
|
763
|
-
Due to auto-imports, barrel exports are less critical in Nuxt. However, for `modules/` (which are NOT auto-imported), each module exports its **public API**:
|
|
764
|
-
|
|
765
|
-
```typescript
|
|
766
|
-
// modules/marketplace/index.ts
|
|
767
|
-
|
|
768
|
-
// Components (for use in pages)
|
|
769
|
-
export { default as MarketplaceList } from './components/MarketplaceList.vue'
|
|
770
|
-
export { default as MarketplaceCard } from './components/MarketplaceCard.vue'
|
|
771
|
-
|
|
772
|
-
// Types (for typing)
|
|
773
|
-
export type { MarketplaceItem, MarketplaceList } from './types/marketplace.contracts'
|
|
774
|
-
|
|
775
|
-
// DO NOT export:
|
|
776
|
-
// - services (internal detail)
|
|
777
|
-
// - adapters (internal detail)
|
|
778
|
-
// - stores (use via composable)
|
|
779
|
-
// - internal composables
|
|
780
|
-
```
|
|
781
|
-
|
|
782
|
-
---
|
|
783
|
-
|
|
784
|
-
## 9. SOLID Applied to Nuxt
|
|
785
|
-
|
|
786
|
-
| Principle | Application in Nuxt |
|
|
787
|
-
|-----------|---------------------|
|
|
788
|
-
| **S**ingle Responsibility | 1 component = 1 responsibility. 1 composable = 1 domain. 1 server route = 1 operation. |
|
|
789
|
-
| **O**pen/Closed | Components extensible via slots and props, not internal modification. |
|
|
790
|
-
| **L**iskov Substitution | Shared components must work in any context without breaking. |
|
|
791
|
-
| **I**nterface Segregation | Specific props, not generic objects. `<UserAvatar :src :alt>` not `<UserAvatar :user>`. |
|
|
792
|
-
| **D**ependency Inversion | Composables depend on interfaces (types), not implementations. Services injected via composable. |
|
|
793
|
-
|
|
794
|
-
---
|
|
795
|
-
|
|
796
|
-
## 10. Migration Checklist (Nuxt 2 -> Nuxt 3)
|
|
797
|
-
|
|
798
|
-
### Nuxt Configuration
|
|
799
|
-
- [ ] `nuxt.config.js` -> `nuxt.config.ts`
|
|
800
|
-
- [ ] `buildModules` -> `modules` (no distinction in Nuxt 3)
|
|
801
|
-
- [ ] `@nuxtjs/` modules -> Nuxt 3 compatible alternatives
|
|
802
|
-
|
|
803
|
-
### Data Fetching
|
|
804
|
-
- [ ] `asyncData()` -> `useAsyncData()`
|
|
805
|
-
- [ ] `fetch()` -> `useFetch()`
|
|
806
|
-
- [ ] `$axios` / `@nuxtjs/axios` -> `$fetch` (built-in)
|
|
807
|
-
|
|
808
|
-
### State Management
|
|
809
|
-
- [ ] `store/` (Vuex) -> `composables/` + `useState` or Pinia
|
|
810
|
-
- [ ] Vuex modules -> Pinia stores (setup syntax)
|
|
811
|
-
|
|
812
|
-
### Components
|
|
813
|
-
- [ ] Options API -> `<script setup lang="ts">`
|
|
814
|
-
- [ ] `this.$route` -> `useRoute()`
|
|
815
|
-
- [ ] `this.$router` -> `useRouter()`
|
|
816
|
-
- [ ] `this.$store` -> composables / Pinia
|
|
817
|
-
- [ ] `this.$refs` -> `useTemplateRef()`
|
|
818
|
-
|
|
819
|
-
### Plugins
|
|
820
|
-
- [ ] `plugins/*.js` -> `plugins/*.ts`
|
|
821
|
-
- [ ] `inject()` pattern -> `provide()` + composables
|
|
822
|
-
- [ ] `context` parameter -> `useNuxtApp()`, `useRuntimeConfig()`
|
|
823
|
-
|
|
824
|
-
### Middleware
|
|
825
|
-
- [ ] `middleware/*.js` -> `middleware/*.ts`
|
|
826
|
-
- [ ] `context` parameter -> `navigateTo()`, `abortNavigation()`
|
|
827
|
-
|
|
828
|
-
### File Structure
|
|
829
|
-
- [ ] `static/` -> `public/`
|
|
830
|
-
- [ ] `store/` -> composables or Pinia
|
|
831
|
-
- [ ] Manual imports -> auto-imports (composables/, components/, utils/)
|