create-velox-app 0.6.61 → 0.6.62
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/CHANGELOG.md +6 -0
- package/dist/templates/placeholders.d.ts +2 -0
- package/dist/templates/placeholders.js +14 -0
- package/package.json +1 -1
- package/src/templates/source/root/CLAUDE.auth.md +105 -1
- package/src/templates/source/root/CLAUDE.default.md +72 -1
- package/src/templates/source/root/CLAUDE.trpc.md +58 -1
- package/src/templates/source/root/package.json +1 -0
- package/src/templates/source/rsc/CLAUDE.md +69 -0
- package/src/templates/source/rsc/package.json +2 -0
- package/src/templates/source/rsc-auth/CLAUDE.md +100 -0
- package/src/templates/source/rsc-auth/package.json +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -32,6 +32,8 @@ export declare const PLACEHOLDERS: {
|
|
|
32
32
|
readonly DATABASE_PROVIDER: "__DATABASE_PROVIDER__";
|
|
33
33
|
/** Database URL for .env files */
|
|
34
34
|
readonly DATABASE_URL: "__DATABASE_URL__";
|
|
35
|
+
/** Display-friendly database name (SQLite, PostgreSQL) */
|
|
36
|
+
readonly DATABASE_DISPLAY: "__DATABASE_DISPLAY__";
|
|
35
37
|
};
|
|
36
38
|
/**
|
|
37
39
|
* Default template configuration for templates that don't need real values.
|
|
@@ -35,6 +35,8 @@ export const PLACEHOLDERS = {
|
|
|
35
35
|
DATABASE_PROVIDER: '__DATABASE_PROVIDER__',
|
|
36
36
|
/** Database URL for .env files */
|
|
37
37
|
DATABASE_URL: '__DATABASE_URL__',
|
|
38
|
+
/** Display-friendly database name (SQLite, PostgreSQL) */
|
|
39
|
+
DATABASE_DISPLAY: '__DATABASE_DISPLAY__',
|
|
38
40
|
};
|
|
39
41
|
/**
|
|
40
42
|
* Default template configuration for templates that don't need real values.
|
|
@@ -141,6 +143,17 @@ function getDatabaseUrl(database) {
|
|
|
141
143
|
}
|
|
142
144
|
return 'file:./dev.db';
|
|
143
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Get the display-friendly database name.
|
|
148
|
+
*/
|
|
149
|
+
function getDatabaseDisplay(database) {
|
|
150
|
+
const displayNames = {
|
|
151
|
+
sqlite: 'SQLite',
|
|
152
|
+
postgresql: 'PostgreSQL',
|
|
153
|
+
mysql: 'MySQL',
|
|
154
|
+
};
|
|
155
|
+
return displayNames[database];
|
|
156
|
+
}
|
|
144
157
|
/**
|
|
145
158
|
* Apply placeholder replacements to template content.
|
|
146
159
|
*
|
|
@@ -164,6 +177,7 @@ export function applyPlaceholders(content, config) {
|
|
|
164
177
|
[PLACEHOLDERS.WEB_PORT]: '8080',
|
|
165
178
|
[PLACEHOLDERS.DATABASE_PROVIDER]: config.database,
|
|
166
179
|
[PLACEHOLDERS.DATABASE_URL]: getDatabaseUrl(config.database),
|
|
180
|
+
[PLACEHOLDERS.DATABASE_DISPLAY]: getDatabaseDisplay(config.database),
|
|
167
181
|
};
|
|
168
182
|
let result = content;
|
|
169
183
|
for (const [placeholder, value] of Object.entries(replacements)) {
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ This file provides guidance to Claude Code and other AI assistants.
|
|
|
7
7
|
**__PROJECT_NAME__** is a VeloxTS full-stack application with:
|
|
8
8
|
- **Backend**: Fastify + VeloxTS (apps/api)
|
|
9
9
|
- **Frontend**: React + Vite + TanStack Router (apps/web)
|
|
10
|
-
- **Database**: Prisma with
|
|
10
|
+
- **Database**: Prisma with __DATABASE_DISPLAY__
|
|
11
11
|
- **Auth**: JWT authentication with guards
|
|
12
12
|
|
|
13
13
|
## Commands
|
|
@@ -142,6 +142,110 @@ JWT_REFRESH_SECRET=<64+ chars> # Generate: openssl rand -base64 64
|
|
|
142
142
|
| `patchUser` | PATCH | `/users/:id` |
|
|
143
143
|
| `deleteUser` | DELETE | `/users/:id` |
|
|
144
144
|
|
|
145
|
+
## Common Gotchas (IMPORTANT)
|
|
146
|
+
|
|
147
|
+
These patterns prevent common mistakes when building VeloxTS applications.
|
|
148
|
+
|
|
149
|
+
### Procedure Builder Syntax
|
|
150
|
+
|
|
151
|
+
**Always call `procedure()` with parentheses:**
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// ✅ Correct
|
|
155
|
+
getCampaign: procedure()
|
|
156
|
+
.guard(authenticated)
|
|
157
|
+
.input(schema)
|
|
158
|
+
.query(...)
|
|
159
|
+
|
|
160
|
+
// ❌ Wrong - causes "procedure.guard is not a function"
|
|
161
|
+
getCampaign: procedure
|
|
162
|
+
.guard(authenticated)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Custom REST Routes
|
|
166
|
+
|
|
167
|
+
When using `.rest()` to override routes, do NOT include the API prefix:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
// ✅ Correct - prefix is applied automatically
|
|
171
|
+
.rest({ method: 'POST', path: '/campaigns/:id/activate' })
|
|
172
|
+
|
|
173
|
+
// ❌ Wrong - results in /api/api/campaigns/:id/activate
|
|
174
|
+
.rest({ method: 'POST', path: '/api/campaigns/:id/activate' })
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Note:** Path parameters (`:id`) are NOT auto-extracted into input. Pass them in the request body.
|
|
178
|
+
|
|
179
|
+
### Handling Prisma Decimals in Zod Schemas
|
|
180
|
+
|
|
181
|
+
Prisma returns `Decimal` objects for decimal fields. Standard Zod validation fails.
|
|
182
|
+
|
|
183
|
+
**Input schemas** - use `z.coerce.number()`:
|
|
184
|
+
```typescript
|
|
185
|
+
bidAmount: z.coerce.number().positive().max(1000)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Output schemas** - use `z.any().transform()`:
|
|
189
|
+
```typescript
|
|
190
|
+
bidAmount: z.any().transform((val) => Number(val))
|
|
191
|
+
balance: z.any().transform((val) => Number(val))
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Dates** - use `z.coerce.date()`:
|
|
195
|
+
```typescript
|
|
196
|
+
createdAt: z.coerce.date()
|
|
197
|
+
updatedAt: z.coerce.date()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Extending User Context
|
|
201
|
+
|
|
202
|
+
The `ctx.user` object is populated by `userLoader` in `src/config/auth.ts`.
|
|
203
|
+
|
|
204
|
+
To add fields to `ctx.user` (e.g., `organizationId`):
|
|
205
|
+
|
|
206
|
+
1. Update `userLoader`:
|
|
207
|
+
```typescript
|
|
208
|
+
async function userLoader(userId: string) {
|
|
209
|
+
const user = await db.user.findUnique({ where: { id: userId } });
|
|
210
|
+
return {
|
|
211
|
+
id: user.id,
|
|
212
|
+
email: user.email,
|
|
213
|
+
roles: parseUserRoles(user.roles),
|
|
214
|
+
organizationId: user.organizationId, // Add new fields here
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
2. Update related schemas (`UserSchema`, `UpdateUserInput`, etc.).
|
|
220
|
+
|
|
221
|
+
### Role Configuration
|
|
222
|
+
|
|
223
|
+
Roles are stored as a JSON string array in the database (e.g., `["ADMIN"]`).
|
|
224
|
+
|
|
225
|
+
When changing roles, update ALL locations:
|
|
226
|
+
- `prisma/schema.prisma` - Role enum
|
|
227
|
+
- `src/config/auth.ts` - `ALLOWED_ROLES` and `parseUserRoles`
|
|
228
|
+
- `src/utils/auth.ts` - `ALLOWED_ROLES` (if duplicated)
|
|
229
|
+
- `src/schemas/auth.ts` - Role validation schemas
|
|
230
|
+
|
|
231
|
+
### MCP Project Path
|
|
232
|
+
|
|
233
|
+
For Claude Desktop, specify the project path explicitly in `.mcp.json`:
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"mcpServers": {
|
|
238
|
+
"velox": {
|
|
239
|
+
"command": "npx",
|
|
240
|
+
"args": ["@veloxts/mcp"],
|
|
241
|
+
"cwd": "/path/to/your/project"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
CLI fallback: `__RUN_CMD__ velox make procedure Posts --crud`
|
|
248
|
+
|
|
145
249
|
## Guards and Policies
|
|
146
250
|
|
|
147
251
|
### Using Guards
|
|
@@ -7,7 +7,7 @@ This file provides guidance to Claude Code and other AI assistants.
|
|
|
7
7
|
**__PROJECT_NAME__** is a VeloxTS full-stack application with:
|
|
8
8
|
- **Backend**: Fastify + VeloxTS (apps/api)
|
|
9
9
|
- **Frontend**: React + Vite + TanStack Router (apps/web)
|
|
10
|
-
- **Database**: Prisma with
|
|
10
|
+
- **Database**: Prisma with __DATABASE_DISPLAY__
|
|
11
11
|
|
|
12
12
|
## Commands
|
|
13
13
|
|
|
@@ -122,6 +122,77 @@ VeloxTS provides end-to-end type safety without code generation:
|
|
|
122
122
|
| `patchUser` | PATCH | `/users/:id` |
|
|
123
123
|
| `deleteUser` | DELETE | `/users/:id` |
|
|
124
124
|
|
|
125
|
+
## Common Gotchas (IMPORTANT)
|
|
126
|
+
|
|
127
|
+
These patterns prevent common mistakes when building VeloxTS applications.
|
|
128
|
+
|
|
129
|
+
### Procedure Builder Syntax
|
|
130
|
+
|
|
131
|
+
**Always call `procedure()` with parentheses:**
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
// ✅ Correct
|
|
135
|
+
getPost: procedure()
|
|
136
|
+
.input(schema)
|
|
137
|
+
.query(...)
|
|
138
|
+
|
|
139
|
+
// ❌ Wrong - causes "procedure.input is not a function"
|
|
140
|
+
getPost: procedure
|
|
141
|
+
.input(schema)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Custom REST Routes
|
|
145
|
+
|
|
146
|
+
When using `.rest()` to override routes, do NOT include the API prefix:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// ✅ Correct - prefix is applied automatically
|
|
150
|
+
.rest({ method: 'POST', path: '/posts/:id/publish' })
|
|
151
|
+
|
|
152
|
+
// ❌ Wrong - results in /api/api/posts/:id/publish
|
|
153
|
+
.rest({ method: 'POST', path: '/api/posts/:id/publish' })
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Note:** Path parameters (`:id`) are NOT auto-extracted into input. Pass them in the request body.
|
|
157
|
+
|
|
158
|
+
### Handling Prisma Decimals in Zod Schemas
|
|
159
|
+
|
|
160
|
+
Prisma returns `Decimal` objects for decimal fields. Standard Zod validation fails.
|
|
161
|
+
|
|
162
|
+
**Input schemas** - use `z.coerce.number()`:
|
|
163
|
+
```typescript
|
|
164
|
+
price: z.coerce.number().positive()
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Output schemas** - use `z.any().transform()`:
|
|
168
|
+
```typescript
|
|
169
|
+
price: z.any().transform((val) => Number(val))
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Dates** - use `z.coerce.date()`:
|
|
173
|
+
```typescript
|
|
174
|
+
createdAt: z.coerce.date()
|
|
175
|
+
updatedAt: z.coerce.date()
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### MCP Project Path
|
|
179
|
+
|
|
180
|
+
For Claude Desktop, specify the project path explicitly in `.mcp.json`:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"mcpServers": {
|
|
185
|
+
"velox": {
|
|
186
|
+
"command": "npx",
|
|
187
|
+
"args": ["@veloxts/mcp"],
|
|
188
|
+
"cwd": "/path/to/your/project"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
CLI fallback: `__RUN_CMD__ velox make procedure Posts --crud`
|
|
195
|
+
|
|
125
196
|
## Database
|
|
126
197
|
|
|
127
198
|
After schema changes:
|
|
@@ -7,7 +7,7 @@ This file provides guidance to Claude Code and other AI assistants.
|
|
|
7
7
|
**__PROJECT_NAME__** is a VeloxTS full-stack application using **tRPC-only** architecture:
|
|
8
8
|
- **Backend**: Fastify + VeloxTS + tRPC (apps/api)
|
|
9
9
|
- **Frontend**: React + Vite + TanStack Router (apps/web)
|
|
10
|
-
- **Database**: Prisma with
|
|
10
|
+
- **Database**: Prisma with __DATABASE_DISPLAY__
|
|
11
11
|
|
|
12
12
|
This template uses tRPC exclusively for type-safe internal communication. No REST adapter is included.
|
|
13
13
|
|
|
@@ -181,6 +181,63 @@ This auto-generates REST endpoints from procedure names:
|
|
|
181
181
|
- `posts.byId` → `GET /api/posts/:id`
|
|
182
182
|
- `posts.create` → `POST /api/posts`
|
|
183
183
|
|
|
184
|
+
## Common Gotchas (IMPORTANT)
|
|
185
|
+
|
|
186
|
+
These patterns prevent common mistakes when building VeloxTS applications.
|
|
187
|
+
|
|
188
|
+
### Procedure Builder Syntax
|
|
189
|
+
|
|
190
|
+
**Always call `procedure()` with parentheses:**
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
// ✅ Correct
|
|
194
|
+
list: procedure()
|
|
195
|
+
.output(schema)
|
|
196
|
+
.query(...)
|
|
197
|
+
|
|
198
|
+
// ❌ Wrong - causes "procedure.output is not a function"
|
|
199
|
+
list: procedure
|
|
200
|
+
.output(schema)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Handling Prisma Decimals in Zod Schemas
|
|
204
|
+
|
|
205
|
+
Prisma returns `Decimal` objects for decimal fields. Standard Zod validation fails.
|
|
206
|
+
|
|
207
|
+
**Input schemas** - use `z.coerce.number()`:
|
|
208
|
+
```typescript
|
|
209
|
+
price: z.coerce.number().positive()
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Output schemas** - use `z.any().transform()`:
|
|
213
|
+
```typescript
|
|
214
|
+
price: z.any().transform((val) => Number(val))
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Dates** - use `z.coerce.date()`:
|
|
218
|
+
```typescript
|
|
219
|
+
createdAt: z.coerce.date()
|
|
220
|
+
updatedAt: z.coerce.date()
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### MCP Project Path
|
|
224
|
+
|
|
225
|
+
For Claude Desktop, specify the project path explicitly in `.mcp.json`:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"mcpServers": {
|
|
230
|
+
"velox": {
|
|
231
|
+
"command": "npx",
|
|
232
|
+
"args": ["@veloxts/mcp"],
|
|
233
|
+
"cwd": "/path/to/your/project"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
CLI fallback: `__RUN_CMD__ velox make procedure Posts`
|
|
240
|
+
|
|
184
241
|
## Database
|
|
185
242
|
|
|
186
243
|
After schema changes:
|
|
@@ -157,6 +157,75 @@ __RUN_CMD__ start # Start production server
|
|
|
157
157
|
- `PUT /api/users/:id` - Update user
|
|
158
158
|
- `DELETE /api/users/:id` - Delete user
|
|
159
159
|
|
|
160
|
+
## Common Gotchas (IMPORTANT)
|
|
161
|
+
|
|
162
|
+
These patterns prevent common mistakes when building VeloxTS applications.
|
|
163
|
+
|
|
164
|
+
### Procedure Builder Syntax
|
|
165
|
+
|
|
166
|
+
**Always call `procedure()` with parentheses:**
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
// ✅ Correct
|
|
170
|
+
getPost: procedure()
|
|
171
|
+
.input(schema)
|
|
172
|
+
.query(...)
|
|
173
|
+
|
|
174
|
+
// ❌ Wrong - causes "procedure.input is not a function"
|
|
175
|
+
getPost: procedure
|
|
176
|
+
.input(schema)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Custom REST Routes
|
|
180
|
+
|
|
181
|
+
When using `.rest()` to override routes, do NOT include the API prefix:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// ✅ Correct - prefix is applied automatically
|
|
185
|
+
.rest({ method: 'POST', path: '/posts/:id/publish' })
|
|
186
|
+
|
|
187
|
+
// ❌ Wrong - results in /api/api/posts/:id/publish
|
|
188
|
+
.rest({ method: 'POST', path: '/api/posts/:id/publish' })
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Handling Prisma Decimals in Zod Schemas
|
|
192
|
+
|
|
193
|
+
Prisma returns `Decimal` objects for decimal fields. Standard Zod validation fails.
|
|
194
|
+
|
|
195
|
+
**Input schemas** - use `z.coerce.number()`:
|
|
196
|
+
```typescript
|
|
197
|
+
price: z.coerce.number().positive()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Output schemas** - use `z.any().transform()`:
|
|
201
|
+
```typescript
|
|
202
|
+
price: z.any().transform((val) => Number(val))
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Dates** - use `z.coerce.date()`:
|
|
206
|
+
```typescript
|
|
207
|
+
createdAt: z.coerce.date()
|
|
208
|
+
updatedAt: z.coerce.date()
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### MCP Project Path
|
|
212
|
+
|
|
213
|
+
For Claude Desktop, specify the project path explicitly in `.mcp.json`:
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"mcpServers": {
|
|
218
|
+
"velox": {
|
|
219
|
+
"command": "npx",
|
|
220
|
+
"args": ["@veloxts/mcp"],
|
|
221
|
+
"cwd": "/path/to/your/project"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
CLI fallback: `__RUN_CMD__ velox make procedure Posts --crud`
|
|
228
|
+
|
|
160
229
|
## AI-Powered Development with MCP
|
|
161
230
|
|
|
162
231
|
VeloxTS includes a **Model Context Protocol (MCP) server** that gives AI assistants like Claude direct access to your project structure. This enables intelligent code assistance with full awareness of your procedures, schemas, routes, and error codes.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"dev": "vinxi dev --port __API_PORT__",
|
|
8
8
|
"build": "vinxi build",
|
|
9
9
|
"start": "vinxi start --port __API_PORT__",
|
|
10
|
+
"velox": "velox",
|
|
10
11
|
"db:generate": "prisma generate",
|
|
11
12
|
"db:push": "prisma db push",
|
|
12
13
|
"db:migrate": "prisma migrate dev",
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
"@types/node": "25.0.3",
|
|
36
37
|
"@types/react": "19.2.7",
|
|
37
38
|
"@types/react-dom": "19.2.3",
|
|
39
|
+
"@veloxts/cli": "__VELOXTS_VERSION__",
|
|
38
40
|
"prisma": "7.2.0",
|
|
39
41
|
"typescript": "5.9.3"
|
|
40
42
|
}
|
|
@@ -229,6 +229,106 @@ JWT_REFRESH_SECRET="..."
|
|
|
229
229
|
- `PUT /api/users/:id` - Update user
|
|
230
230
|
- `DELETE /api/users/:id` - Delete user
|
|
231
231
|
|
|
232
|
+
## Common Gotchas (IMPORTANT)
|
|
233
|
+
|
|
234
|
+
These patterns prevent common mistakes when building VeloxTS applications.
|
|
235
|
+
|
|
236
|
+
### Procedure Builder Syntax
|
|
237
|
+
|
|
238
|
+
**Always call `procedure()` with parentheses:**
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
// ✅ Correct
|
|
242
|
+
getUser: procedure()
|
|
243
|
+
.guard(authenticated)
|
|
244
|
+
.input(schema)
|
|
245
|
+
.query(...)
|
|
246
|
+
|
|
247
|
+
// ❌ Wrong - causes "procedure.guard is not a function"
|
|
248
|
+
getUser: procedure
|
|
249
|
+
.guard(authenticated)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Custom REST Routes
|
|
253
|
+
|
|
254
|
+
When using `.rest()` to override routes, do NOT include the API prefix:
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
// ✅ Correct - prefix is applied automatically
|
|
258
|
+
.rest({ method: 'POST', path: '/users/:id/activate' })
|
|
259
|
+
|
|
260
|
+
// ❌ Wrong - results in /api/api/users/:id/activate
|
|
261
|
+
.rest({ method: 'POST', path: '/api/users/:id/activate' })
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Handling Prisma Decimals in Zod Schemas
|
|
265
|
+
|
|
266
|
+
Prisma returns `Decimal` objects for decimal fields. Standard Zod validation fails.
|
|
267
|
+
|
|
268
|
+
**Input schemas** - use `z.coerce.number()`:
|
|
269
|
+
```typescript
|
|
270
|
+
price: z.coerce.number().positive()
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Output schemas** - use `z.any().transform()`:
|
|
274
|
+
```typescript
|
|
275
|
+
price: z.any().transform((val) => Number(val))
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
**Dates** - use `z.coerce.date()`:
|
|
279
|
+
```typescript
|
|
280
|
+
createdAt: z.coerce.date()
|
|
281
|
+
updatedAt: z.coerce.date()
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Extending User Context
|
|
285
|
+
|
|
286
|
+
The `ctx.user` object is populated by `userLoader` in `src/api/utils/auth.ts`.
|
|
287
|
+
|
|
288
|
+
To add fields to `ctx.user` (e.g., `organizationId`):
|
|
289
|
+
|
|
290
|
+
1. Update `userLoader`:
|
|
291
|
+
```typescript
|
|
292
|
+
async function userLoader(userId: string) {
|
|
293
|
+
const user = await db.user.findUnique({ where: { id: userId } });
|
|
294
|
+
return {
|
|
295
|
+
id: user.id,
|
|
296
|
+
email: user.email,
|
|
297
|
+
roles: parseUserRoles(user.roles),
|
|
298
|
+
organizationId: user.organizationId, // Add new fields here
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
2. Update related schemas (`UserSchema`, `UpdateUserInput`, etc.).
|
|
304
|
+
|
|
305
|
+
### Role Configuration
|
|
306
|
+
|
|
307
|
+
Roles are stored as a JSON string array in the database (e.g., `["ADMIN"]`).
|
|
308
|
+
|
|
309
|
+
When changing roles, update ALL locations:
|
|
310
|
+
- `prisma/schema.prisma` - Role enum
|
|
311
|
+
- `src/api/utils/auth.ts` - `ALLOWED_ROLES` and `parseUserRoles`
|
|
312
|
+
- `src/api/schemas/auth.ts` - Role validation schemas
|
|
313
|
+
|
|
314
|
+
### MCP Project Path
|
|
315
|
+
|
|
316
|
+
For Claude Desktop, specify the project path explicitly in `.mcp.json`:
|
|
317
|
+
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"mcpServers": {
|
|
321
|
+
"velox": {
|
|
322
|
+
"command": "npx",
|
|
323
|
+
"args": ["@veloxts/mcp"],
|
|
324
|
+
"cwd": "/path/to/your/project"
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
CLI fallback: `__RUN_CMD__ velox make procedure Posts --crud`
|
|
331
|
+
|
|
232
332
|
## AI-Powered Development with MCP
|
|
233
333
|
|
|
234
334
|
VeloxTS includes a **Model Context Protocol (MCP) server** that gives AI assistants like Claude direct access to your project structure. This enables intelligent code assistance with full awareness of your procedures, schemas, routes, and error codes.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"dev": "vinxi dev --port __API_PORT__",
|
|
8
8
|
"build": "vinxi build",
|
|
9
9
|
"start": "vinxi start --port __API_PORT__",
|
|
10
|
+
"velox": "velox",
|
|
10
11
|
"db:generate": "prisma generate",
|
|
11
12
|
"db:push": "prisma db push",
|
|
12
13
|
"db:migrate": "prisma migrate dev",
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
"@types/node": "25.0.3",
|
|
39
40
|
"@types/react": "19.2.7",
|
|
40
41
|
"@types/react-dom": "19.2.3",
|
|
42
|
+
"@veloxts/cli": "__VELOXTS_VERSION__",
|
|
41
43
|
"prisma": "7.2.0",
|
|
42
44
|
"typescript": "5.9.3"
|
|
43
45
|
}
|