@donotdev/cli 0.0.37 → 0.1.1

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 (119) hide show
  1. package/LICENSE.md +21 -48
  2. package/dependencies-matrix.json +108 -58
  3. package/dist/bin/commands/agent-setup.js +7196 -123
  4. package/dist/bin/commands/build.js +3341 -207
  5. package/dist/bin/commands/bump.js +268 -24
  6. package/dist/bin/commands/cacheout.js +262 -13
  7. package/dist/bin/commands/coach.js +365 -61
  8. package/dist/bin/commands/create-app.js +261 -14
  9. package/dist/bin/commands/create-project.js +270 -15
  10. package/dist/bin/commands/db.js +10743 -2346
  11. package/dist/bin/commands/deploy.js +4202 -776
  12. package/dist/bin/commands/dev.js +353 -38
  13. package/dist/bin/commands/doctor.js +412 -108
  14. package/dist/bin/commands/emu.js +392 -57
  15. package/dist/bin/commands/format.js +250 -15
  16. package/dist/bin/commands/get-demo.js +261 -14
  17. package/dist/bin/commands/make-admin.js +10022 -1552
  18. package/dist/bin/commands/preview.js +353 -38
  19. package/dist/bin/commands/seed.js +10743 -2346
  20. package/dist/bin/commands/setup-cicd.js +456 -133
  21. package/dist/bin/commands/setup.js +428 -125
  22. package/dist/bin/commands/staging.js +4202 -776
  23. package/dist/bin/commands/sync-secrets.js +250 -14
  24. package/dist/bin/commands/type-check.js +249 -13
  25. package/dist/bin/commands/wai.js +249 -13
  26. package/dist/bin/dndev.js +33 -4
  27. package/dist/bin/donotdev.js +33 -4
  28. package/dist/index.js +4278 -856
  29. package/{templates/root-consumer/guides/dndev/advanced/VERSION_CONTROL.md.example → guidelines/VERSION_CONTROL.md} +7 -11
  30. package/package.json +3 -2
  31. package/templates/app-demo/src/themes.css.example +21 -0
  32. package/templates/app-dndev/index.html.example +0 -3
  33. package/templates/app-dndev/src/themes.css.example +21 -0
  34. package/templates/app-next/src/app/layout.tsx.example +13 -4
  35. package/templates/app-next/src/themes.css.example +21 -0
  36. package/templates/app-vite/csp.example.json +44 -0
  37. package/templates/app-vite/index.html.example +0 -3
  38. package/templates/app-vite/src/themes.css.example +21 -0
  39. package/templates/functions-supabase/supabase/functions/.env.example +12 -0
  40. package/templates/functions-supabase/supabase/functions/disconnect-oauth/index.ts.example +7 -0
  41. package/templates/functions-supabase/supabase/functions/exchange-token/index.ts.example +7 -0
  42. package/templates/functions-supabase/supabase/functions/get-connections/index.ts.example +7 -0
  43. package/templates/functions-supabase/supabase/functions/refresh-token/index.ts.example +7 -0
  44. package/templates/functions-supabase/supabase/migrations/20250101000000_idempotency.sql +3 -0
  45. package/templates/functions-supabase/supabase/migrations/20250101000001_rate_limits.sql +3 -0
  46. package/templates/functions-supabase/supabase/migrations/20250101000003_operation_metrics.sql +3 -0
  47. package/templates/preset-admin/src/pages/DashboardPage.tsx.example +189 -0
  48. package/templates/preset-admin/src/pages/EntityPage.tsx.example +84 -0
  49. package/templates/preset-admin/src/pages/ReportsPage.tsx.example +243 -0
  50. package/templates/preset-admin/src/pages/SettingsPage.tsx.example +283 -0
  51. package/templates/preset-admin/src/pages/UsersPage.tsx.example +128 -0
  52. package/templates/preset-ecommerce/src/pages/CartPage.tsx.example +167 -0
  53. package/templates/preset-ecommerce/src/pages/CatalogPage.tsx.example +187 -0
  54. package/templates/preset-ecommerce/src/pages/CheckoutPage.tsx.example +244 -0
  55. package/templates/preset-ecommerce/src/pages/HomePage.tsx.example +268 -0
  56. package/templates/preset-ecommerce/src/pages/ProductPage.tsx.example +228 -0
  57. package/templates/preset-landing/src/pages/AboutPage.tsx.example +237 -0
  58. package/templates/preset-landing/src/pages/ContactPage.tsx.example +192 -0
  59. package/templates/preset-landing/src/pages/HomePage.tsx.example +399 -0
  60. package/templates/preset-saas/src/pages/DashboardPage.tsx.example +195 -0
  61. package/templates/preset-saas/src/pages/HomePage.tsx.example +270 -0
  62. package/templates/preset-saas/src/pages/PricingPage.tsx.example +204 -0
  63. package/templates/preset-saas/src/pages/ProfilePage.tsx.example +191 -0
  64. package/templates/preset-saas/src/pages/SettingsPage.tsx.example +292 -0
  65. package/templates/root-consumer/.claude/hooks/framework-compliance.sh.example +56 -0
  66. package/templates/root-consumer/.claude/hooks/guard-bash.sh.example +61 -0
  67. package/templates/root-consumer/.claude/hooks/guard-files.sh.example +46 -0
  68. package/templates/root-consumer/.claude/hooks/guard-mcp.sh.example +91 -0
  69. package/templates/root-consumer/.claude/hooks/guard-secrets.sh.example +67 -0
  70. package/templates/root-consumer/.claude/hooks/guard-write.sh.example +89 -0
  71. package/templates/root-consumer/.claude/hooks/session-start.sh.example +50 -0
  72. package/templates/root-consumer/.claude/hooks/track-mcp-lookup.sh.example +20 -0
  73. package/templates/root-consumer/.claude/hooks/typecheck-stop.sh.example +18 -0
  74. package/templates/root-consumer/.claude/rules/consumer-ux.md.example +32 -0
  75. package/templates/root-consumer/.claude/rules/definition-of-done.md.example +32 -0
  76. package/templates/root-consumer/.claude/rules/framework.md.example +39 -0
  77. package/templates/root-consumer/.claude/rules/git.md.example +14 -0
  78. package/templates/root-consumer/.claude/rules/security.md.example +13 -0
  79. package/templates/root-consumer/.claude/settings.json.example +123 -1
  80. package/templates/root-consumer/.claude/skills/brainstorm/SKILL.md.example +16 -0
  81. package/templates/root-consumer/.claude/skills/build/SKILL.md.example +103 -25
  82. package/templates/root-consumer/.claude/skills/design/SKILL.md.example +17 -0
  83. package/templates/root-consumer/.claude/skills/grill/SKILL.md.example +33 -16
  84. package/templates/root-consumer/.claude/skills/polish/SKILL.md.example +50 -37
  85. package/templates/root-consumer/AI.md.example +2 -2
  86. package/templates/root-consumer/CLAUDE.md.example +33 -1
  87. package/templates/root-consumer/guides/dndev/INDEX.md.example +23 -27
  88. package/templates/root-consumer/guides/dndev/SETUP_AUTH.md.example +3 -2
  89. package/templates/root-consumer/guides/dndev/SETUP_OAUTH.md.example +12 -6
  90. package/templates/root-consumer/guides/dndev/SETUP_SUPABASE.md.example +50 -3
  91. package/templates/root-consumer/guides/wai-way/blueprints/3_compose.md.example +13 -15
  92. package/templates/app-demo/public/manifest.json.example +0 -10
  93. package/templates/app-dndev/public/manifest.json.example +0 -10
  94. package/templates/root-consumer/.claude/commands/brainstorm.md.example +0 -147
  95. package/templates/root-consumer/.claude/commands/build.md.example +0 -131
  96. package/templates/root-consumer/.claude/commands/design.md.example +0 -153
  97. package/templates/root-consumer/.claude/commands/grill.md.example +0 -108
  98. package/templates/root-consumer/.claude/commands/polish.md.example +0 -146
  99. package/templates/root-consumer/.claude/commands/techdebt.md.example +0 -28
  100. package/templates/root-consumer/guides/dndev/COMPONENTS_ATOMIC.md.example +0 -180
  101. package/templates/root-consumer/guides/dndev/COMPONENTS_CRUD.md.example +0 -234
  102. package/templates/root-consumer/guides/dndev/COMPONENTS_UI.md.example +0 -136
  103. package/templates/root-consumer/guides/dndev/COMPONENT_API.md.example +0 -195
  104. package/templates/root-consumer/guides/dndev/ENV_SETUP.md.example +0 -219
  105. package/templates/root-consumer/guides/dndev/GOTCHAS.md.example +0 -197
  106. package/templates/root-consumer/guides/dndev/SETUP_APP_CONFIG.md.example +0 -132
  107. package/templates/root-consumer/guides/dndev/SETUP_BLOG.md.example +0 -280
  108. package/templates/root-consumer/guides/dndev/SETUP_CICD.md.example +0 -115
  109. package/templates/root-consumer/guides/dndev/SETUP_CRUD.md.example +0 -334
  110. package/templates/root-consumer/guides/dndev/SETUP_FUNCTIONS.md.example +0 -9
  111. package/templates/root-consumer/guides/dndev/SETUP_I18N.md.example +0 -233
  112. package/templates/root-consumer/guides/dndev/SETUP_LAYOUTS.md.example +0 -158
  113. package/templates/root-consumer/guides/dndev/SETUP_PAGES.md.example +0 -205
  114. package/templates/root-consumer/guides/dndev/SETUP_PWA.md.example +0 -213
  115. package/templates/root-consumer/guides/dndev/SETUP_TESTING.md.example +0 -184
  116. package/templates/root-consumer/guides/dndev/SETUP_THEMES.md.example +0 -111
  117. package/templates/root-consumer/guides/dndev/SETUP_VERCEL.md.example +0 -260
  118. package/templates/root-consumer/guides/dndev/USE_ROUTING.md.example +0 -499
  119. package/templates/root-consumer/guides/dndev/essences_reference.css.example +0 -288
@@ -1,184 +0,0 @@
1
- # Testing Guide
2
-
3
- ## Setup
4
-
5
- ```bash
6
- bun add -D vitest @testing-library/react @testing-library/jest-dom jsdom
7
- ```
8
-
9
- ### vitest.config.ts
10
-
11
- ```ts
12
- import { defineConfig } from 'vitest/config';
13
- import react from '@vitejs/plugin-react';
14
-
15
- export default defineConfig({
16
- plugins: [react()],
17
- test: {
18
- environment: 'jsdom',
19
- setupFiles: ['./tests/setup.ts'],
20
- globals: true,
21
- include: ['tests/**/*.test.ts', 'tests/**/*.test.tsx'],
22
- },
23
- });
24
- ```
25
-
26
- ### tests/setup.ts
27
-
28
- ```ts
29
- import '@testing-library/jest-dom';
30
- ```
31
-
32
- ### package.json scripts
33
-
34
- ```json
35
- {
36
- "scripts": {
37
- "test": "vitest run",
38
- "test:watch": "vitest"
39
- }
40
- }
41
- ```
42
-
43
- ---
44
-
45
- ## What To Test
46
-
47
- ### 1. Entity Tests
48
-
49
- For each entity defined in `entities/`, test:
50
-
51
- **CRUD operations:**
52
- ```ts
53
- // tests/entities/Task.test.ts
54
- import { describe, it, expect } from 'vitest';
55
- import { TaskEntity } from '../../entities';
56
-
57
- describe('TaskEntity', () => {
58
- it('has correct fields', () => {
59
- const fields = TaskEntity.fields;
60
- expect(fields).toHaveProperty('title');
61
- expect(fields).toHaveProperty('status');
62
- expect(fields.title.required).toBe(true);
63
- });
64
-
65
- it('has correct access rules', () => {
66
- const access = TaskEntity.access;
67
- expect(access.create).toContain('authenticated');
68
- expect(access.read).toContain('owner');
69
- expect(access.delete).toContain('admin');
70
- });
71
- });
72
- ```
73
-
74
- **What to verify per entity:**
75
- - All required fields defined
76
- - Field types match spec
77
- - Access rules match spec (create/read/update/delete per role)
78
- - State transitions valid (if entity has states)
79
- - Default values set correctly
80
-
81
- ### 2. Page Render Tests
82
-
83
- For each page in `src/pages/`, test that it mounts:
84
-
85
- ```tsx
86
- // tests/pages/DashboardPage.test.tsx
87
- import { describe, it, expect } from 'vitest';
88
- import { render, screen } from '@testing-library/react';
89
- import DashboardPage from '../../src/pages/DashboardPage';
90
-
91
- describe('DashboardPage', () => {
92
- it('renders without crashing', () => {
93
- render(<DashboardPage />);
94
- expect(document.body).toBeTruthy();
95
- });
96
-
97
- it('has correct PageMeta', () => {
98
- expect(DashboardPage.meta).toBeDefined();
99
- expect(DashboardPage.meta.title).toBeTruthy();
100
- expect(DashboardPage.meta.auth).toBe(true);
101
- });
102
- });
103
- ```
104
-
105
- **What to verify per page:**
106
- - Page renders without error
107
- - PageMeta is defined (title, auth requirement, admin flag)
108
- - Route protection matches spec (public/auth/admin)
109
-
110
- ### 3. Access Control Tests
111
-
112
- Derive from entity permissions in the spec:
113
-
114
- ```ts
115
- // tests/access/access-rules.test.ts
116
- import { describe, it, expect } from 'vitest';
117
- import { entities } from '../../entities';
118
-
119
- describe('Access Control', () => {
120
- it('admin entities require admin access', () => {
121
- // Entities marked admin-only in spec
122
- const adminEntities = ['AuditLog', 'SystemConfig'];
123
- for (const name of adminEntities) {
124
- const entity = entities[name];
125
- expect(entity.access.create).toContain('admin');
126
- }
127
- });
128
-
129
- it('user-owned entities have owner access', () => {
130
- // Entities where users own their own data
131
- const userEntities = ['Task', 'Profile'];
132
- for (const name of userEntities) {
133
- const entity = entities[name];
134
- expect(entity.access.update).toContain('owner');
135
- }
136
- });
137
- });
138
- ```
139
-
140
- ### 4. Firestore Rules Tests
141
-
142
- If using Firebase, generate rules from entity access definitions:
143
-
144
- ```
145
- // firestore.rules — generated from entities
146
- rules_version = '2';
147
- service cloud.firestore {
148
- match /databases/{database}/documents {
149
-
150
- // TaskEntity: create=authenticated, read=owner, update=owner, delete=admin
151
- match /tasks/{taskId} {
152
- allow create: if request.auth != null;
153
- allow read, update: if request.auth != null && resource.data.userId == request.auth.uid;
154
- allow delete: if request.auth.token.admin == true;
155
- }
156
- }
157
- }
158
- ```
159
-
160
- ---
161
-
162
- ## Test Generation Checklist
163
-
164
- The Polisher agent should generate tests for everything in the spec:
165
-
166
- | Source | Test Type | File |
167
- |--------|-----------|------|
168
- | Each entity | Field validation + access rules | `tests/entities/[Entity].test.ts` |
169
- | Each page | Render + PageMeta | `tests/pages/[Page].test.tsx` |
170
- | Spec permissions | Access control matrix | `tests/access/access-rules.test.ts` |
171
- | Spec auth | Auth provider config | `tests/auth/auth.test.ts` |
172
- | Entity access | Firestore rules | `firestore.rules` |
173
-
174
- ---
175
-
176
- ## Running Tests
177
-
178
- ```bash
179
- bun test # Run all tests once
180
- bun test:watch # Watch mode
181
- bunx vitest --ui # Visual UI
182
- ```
183
-
184
- Tests should pass before calling `complete_phase({ files: [...test files...] })`.
@@ -1,111 +0,0 @@
1
- # Setup: Themes
2
-
3
- **Single source of truth:** `src/themes.css`. Import it from `globals.css`; do not set font/color overrides in globals. Framework handles theme switching.
4
-
5
- **Default essence = SaaS** (Inter, neutral). Optional essences (Brutalist, Luxury) are in the scaffold; they do **not** apply until you set the class on `<html>` (e.g. `class="brutalist"`) or use the theme switcher.
6
-
7
- **Reference:** Copy Brutalist/Luxury blocks from `guides/dndev/essences_reference.css` into your `src/themes.css` if you need them. Default-essence fonts (Inter, Space Grotesk, Playfair, Roboto) are bundled via `@donotdev/ui`; no Google Fonts, no `public/fonts/` required.
8
-
9
- ---
10
-
11
- ## Standard Use
12
-
13
- **File:** `src/themes.css` (scaffolded with light, dark, and optional Brutalist/Luxury)
14
-
15
- **Override colors:**
16
- ```css
17
- :root {
18
- /* Brand colors */
19
- --primary: #2563eb;
20
- --secondary: #9333ea;
21
- --accent: #ec4899;
22
-
23
- /* Base colors */
24
- --background: #ffffff;
25
- --foreground: #000000;
26
- }
27
- ```
28
-
29
- **Add custom theme:**
30
- ```css
31
- .ocean {
32
- --theme-icon: 'Waves';
33
- --theme-label: 'Ocean';
34
- --primary: #0ea5e9;
35
- --background: #001a33;
36
- --foreground: #e0f2fe;
37
- }
38
- ```
39
-
40
- **Framework auto-computes:** Surfaces (card, popover), muted colors, borders, text on brand colors.
41
-
42
- ---
43
-
44
- ## Advanced: All CSS Variables
45
-
46
- **Brand colors:**
47
- ```css
48
- --primary, --secondary, --accent
49
- --primary-foreground, --secondary-foreground, --accent-foreground
50
- ```
51
-
52
- **Base colors:**
53
- ```css
54
- --background, --foreground
55
- ```
56
-
57
- **Status colors:**
58
- ```css
59
- --success, --warning, --destructive
60
- --success-foreground, --warning-foreground, --destructive-foreground
61
- ```
62
-
63
- **Surfaces:**
64
- ```css
65
- --card, --card-foreground
66
- --popover, --popover-foreground
67
- --muted, --muted-foreground
68
- --border, --input, --ring
69
- ```
70
-
71
- **Theme metadata:**
72
- ```css
73
- --theme-icon: 'Sun'; /* Lucide icon name */
74
- --theme-label: 'Light'; /* Display name */
75
- --theme-is-dark: 0; /* 0 = light, 1 = dark */
76
- ```
77
-
78
- ---
79
-
80
- ## Advanced: Styling Overrides
81
-
82
- **Utility classes:**
83
- ```tsx
84
- <Card className="dndev-gap-sm" /> // Gap utilities
85
- <div className="dndev-flex dndev-gap-md" /> // Layout utilities
86
- ```
87
-
88
- **Data attributes:**
89
- ```tsx
90
- <HeroSection data-text-align="center" title="Centered" />
91
- <div data-gap="medium" data-radius="md" />
92
- ```
93
-
94
- **Inline styles:**
95
- ```tsx
96
- <Button style={{ minWidth: '200px' }} />
97
- ```
98
-
99
- **Global CSS rules:**
100
- ```css
101
- /* src/themes.css */
102
- .dndev-button {
103
- border-radius: 8px; /* Override default */
104
- }
105
- ```
106
-
107
- **Framework respects your overrides.** All components use CSS variables, so color changes propagate automatically.
108
-
109
- ---
110
-
111
- **Override variables, get themes. Framework handles the rest.**
@@ -1,260 +0,0 @@
1
- # Setup: Vercel (Hosting & Functions)
2
-
3
- **Deploy your frontend (and optionally serverless functions) to Vercel. Works with any backend (Firebase, Supabase, or both).**
4
-
5
- ---
6
-
7
- ## Architecture
8
-
9
- Vercel serves your built Vite or Next.js app on a global CDN. It can also run **Vercel Functions** (serverless API routes).
10
-
11
- **Vercel as hosting only** (backend elsewhere):
12
- - **Firebase** → Cloud Functions + Firestore + Auth + Storage
13
- - **Supabase** → Edge Functions + PostgreSQL + Auth + Storage
14
-
15
- **Vercel as hosting + functions** (alongside a backend):
16
- - Vercel Functions handle API routes (`/api/*`)
17
- - Combine with Firebase/Supabase for auth + database
18
-
19
- The framework scaffolds `vercel.json` with CSP headers, rewrites, and caching rules.
20
-
21
- ---
22
-
23
- ## Step 1: Create Vercel Project
24
-
25
- 1. Create a [Vercel](https://vercel.com) account
26
- 2. Import your Git repo from the Vercel Dashboard
27
- 3. Set the **Root Directory** to `apps/<your-app>` (or leave blank if monorepo auto-detected)
28
- 4. Set **Framework Preset** to Vite (or Next.js if using Next)
29
-
30
- ---
31
-
32
- ## Step 2: Add Credentials
33
-
34
- **Secret (shared across apps):** add to `.dndev.secrets` at project root:
35
-
36
- ```env
37
- VERCEL_TOKEN=your_vercel_token
38
- ```
39
-
40
- **Per-app (public):** add to `apps/<your-app>/.env`:
41
-
42
- ```env
43
- VERCEL_PROJECT_ID=your_project_id
44
- ```
45
-
46
- **Team/Pro accounts only** — add to `apps/<your-app>/.env`:
47
-
48
- ```env
49
- VERCEL_ORG_ID=your_team_id
50
- ```
51
-
52
- > **Hobby/free accounts: Do NOT set `VERCEL_ORG_ID`.** Setting it on a hobby account causes 403 Forbidden errors. If you're unsure, run `dndev setup` — it detects your account type automatically.
53
-
54
- **Where to find them:**
55
-
56
- | Variable | Where | File | Required? |
57
- |----------|-------|------|-----------|
58
- | `VERCEL_TOKEN` | [vercel.com/account/tokens](https://vercel.com/account/tokens) — scope to your team | `.dndev.secrets` | Always |
59
- | `VERCEL_PROJECT_ID` | Vercel Dashboard → Your Project → Settings → General → **Project ID** | `apps/<app>/.env` | Always |
60
- | `VERCEL_ORG_ID` | Vercel Dashboard → Settings → General → **Team ID** | `apps/<app>/.env` | Team/Pro only |
61
-
62
- That's it. No `vercel login`, no `vercel link`, no interactive prompts. Run `dndev setup` to validate everything.
63
-
64
- ---
65
-
66
- ## Step 3: Set App Environment Variables
67
-
68
- In **Vercel Dashboard → Project → Settings → Environment Variables**, add your app's env vars:
69
-
70
- **If using Firebase:**
71
- - `VITE_FIREBASE_API_KEY`
72
- - `VITE_FIREBASE_PROJECT_ID`
73
- - `VITE_FIREBASE_AUTH_DOMAIN`
74
- - `VITE_FIREBASE_STORAGE_BUCKET`
75
- - `VITE_FIREBASE_MESSAGING_SENDER_ID`
76
- - `VITE_FIREBASE_APP_ID`
77
-
78
- **If using Supabase:**
79
- - `VITE_SUPABASE_URL`
80
- - `VITE_SUPABASE_PUBLIC_KEY`
81
-
82
- **Common (all backends):**
83
- - `VITE_DONOTDEV_LICENSE_KEY`
84
- - `VITE_STRIPE_PUBLISHABLE_KEY` (if using billing)
85
-
86
- **Server-side (Vercel Functions only):**
87
- - `STRIPE_SECRET_KEY` (if using billing)
88
- - `SUPABASE_SERVICE_ROLE_KEY` (if using Supabase)
89
-
90
- For Next.js apps, replace the `VITE_` prefix with `NEXT_PUBLIC_` (same var names, different prefix).
91
-
92
- ---
93
-
94
- ## Step 4: Deploy
95
-
96
- ```bash
97
- dndev deploy
98
- ```
99
-
100
- That's it. The CLI reads your credentials from `.dndev.secrets` and `.env` and deploys to production.
101
-
102
- **Option B — Git push (auto-deploy)**
103
-
104
- If your repo is connected to Vercel, pushing to your branch auto-deploys:
105
-
106
- ```bash
107
- git push origin main
108
- ```
109
-
110
- ---
111
-
112
- ## Vercel Functions (Optional)
113
-
114
- The framework provides helpers for Vercel Functions via `@donotdev/functions/vercel`. Place your API routes in `pages/api/` (Next.js) or `api/` (Vite).
115
-
116
- ### Custom Functions
117
-
118
- ```typescript
119
- // pages/api/product-details.ts
120
- import * as v from 'valibot';
121
- import { createVercelBaseFunction } from '@donotdev/functions/vercel';
122
-
123
- const schema = v.object({ productId: v.string() });
124
-
125
- export default createVercelBaseFunction(
126
- 'POST',
127
- schema,
128
- 'get_product_details',
129
- async (req, res, data, { uid }) => {
130
- // data is validated, uid is the authenticated user
131
- const product = await getProduct(data.productId);
132
- return res.status(200).json(product);
133
- }
134
- );
135
- ```
136
-
137
- Auth, rate limiting, schema validation, and metrics — all included by default.
138
-
139
- ### Pre-built Endpoints
140
-
141
- The framework ships ready-made API handlers:
142
-
143
- ```typescript
144
- // pages/api/auth/claims.ts
145
- import { setCustomClaims } from '@donotdev/functions/vercel';
146
- export default setCustomClaims;
147
-
148
- // pages/api/billing/checkout.ts
149
- import { createCheckoutSession } from '@donotdev/functions/vercel';
150
- import { billingConfig } from '../../../config/billing';
151
- export default createCheckoutSession(billingConfig);
152
- ```
153
-
154
- Available: auth (claims, status, delete account), billing (checkout, cancel, portal, change plan), OAuth (token exchange, access grants).
155
-
156
- ### When to use Vercel Functions vs Firebase/Supabase functions
157
-
158
- - **Vercel Functions:** API routes, webhooks, third-party proxies — especially in Next.js apps
159
- - **Firebase Cloud Functions:** Firestore triggers, heavy backend logic tied to Firebase
160
- - **Supabase Edge Functions:** Database triggers, logic tied to Supabase
161
-
162
- **Server secrets** for Vercel Functions go in Vercel Dashboard → Environment Variables (not `VITE_*` or `NEXT_PUBLIC_*` prefixed — those are exposed to the browser).
163
-
164
- ---
165
-
166
- ## Environment Variables
167
-
168
- | File | What Goes Here | Loaded By |
169
- |------|---------------|-----------|
170
- | `.dndev.secrets` | `VERCEL_TOKEN` (gitignored) | `dndev deploy` |
171
- | `apps/<app>/.env` | Public keys + `VERCEL_ORG_ID`, `VERCEL_PROJECT_ID` | Vite/Next.js + `dndev deploy` |
172
- | `apps/<app>/.env.production` | Production overrides | Vite/Next.js (build --mode production) |
173
- | Vercel Dashboard | All production env vars (client + server) | Vercel runtime |
174
-
175
- **Client vars** (browser-safe): `VITE_*` or `NEXT_PUBLIC_*` prefix.
176
-
177
- ---
178
-
179
- ## Local Development
180
-
181
- ```bash
182
- dndev dev
183
- ```
184
-
185
- The app runs locally, talking to your backend (Firebase or Supabase) directly.
186
-
187
- For local function emulation:
188
-
189
- ```bash
190
- dndev emu start
191
- ```
192
-
193
- ---
194
-
195
- ## Auth Redirect URLs (Supabase)
196
-
197
- After deploying, configure Supabase so OAuth (Google, GitHub, etc.) redirects back to your Vercel URL instead of `localhost`.
198
-
199
- **Supabase Dashboard → Authentication → URL Configuration:**
200
-
201
- | Setting | Value |
202
- |---------|-------|
203
- | **Site URL** | Your production URL (e.g., `https://myapp.vercel.app`) |
204
- | **Redirect URLs** | Add all deployment URLs where auth should work |
205
-
206
- **Redirect URLs to add:**
207
-
208
- - `http://localhost:5173` — local Vite dev
209
- - `http://localhost:3000` — local Next.js dev
210
- - `https://myapp.vercel.app` — production
211
- - `https://*-yourteam.vercel.app` — Vercel preview deploys (wildcard)
212
- - `https://mycustomdomain.com` — custom domain (if applicable)
213
-
214
- > **Site URL is the fallback.** If the `redirectTo` sent by your app doesn't match any entry in Redirect URLs, Supabase falls back to Site URL. If Site URL is `localhost:3000`, your deployed app will redirect to localhost after OAuth. **Always set Site URL to production.**
215
-
216
- ---
217
-
218
- ## Custom Domain
219
-
220
- 1. Vercel Dashboard → Settings → Domains
221
- 2. Add your domain
222
- 3. Update DNS records as instructed by Vercel
223
- 4. If using Firebase Auth: update your `FIREBASE_AUTH_DOMAIN` env var to your custom domain
224
- 5. If using Supabase Auth: add your custom domain to **Supabase Dashboard → Authentication → Redirect URLs** and update **Site URL**
225
-
226
- ---
227
-
228
- ## Troubleshooting
229
-
230
- **"Missing Vercel credentials"**
231
- → Check `VERCEL_TOKEN` is in `.dndev.secrets` at project root
232
- → Check `VERCEL_PROJECT_ID` is in `apps/<app>/.env`
233
- → Run `dndev setup` to validate
234
-
235
- **"403 Forbidden" / "token does not have access"**
236
- → Hobby/free account? Remove `VERCEL_ORG_ID` from `apps/<app>/.env` — hobby accounts don't use team IDs
237
- → Team account? Ensure the token is scoped to the correct team at https://vercel.com/account/tokens
238
-
239
- **"401 Unauthorized" / "token is invalid or expired"**
240
- → Generate a new token at https://vercel.com/account/tokens and update `.dndev.secrets`
241
-
242
- **"404 project not found"**
243
- → Check `VERCEL_PROJECT_ID` matches the Project ID in Vercel Dashboard → Project → Settings → General
244
-
245
- **"Build fails on Vercel"**
246
- → Check Root Directory is set to your app directory
247
- → Ensure `package.json` has correct `build` script
248
- → Check all `VITE_*` env vars are set in Vercel Dashboard
249
-
250
- **"CORS error"**
251
- → Vercel handles CORS for same-origin requests automatically
252
- → For cross-origin: CSP headers in `vercel.json` are pre-configured for your backend
253
-
254
- **".env values not loading"**
255
- → Vercel only reads env vars from its Dashboard, not from `.env` files
256
- → Make sure all required vars are set in Vercel Dashboard → Environment Variables
257
-
258
- ---
259
-
260
- **Token in `.dndev.secrets` + IDs in `.env` → `dndev deploy` → done.**