create-velox-app 0.6.93 → 0.6.95

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # create-velox-app
2
2
 
3
+ ## 0.6.95
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(create): use /trpc baseUrl for tRPC template and unwrap tRPC response format
8
+
9
+ ## 0.6.94
10
+
11
+ ### Patch Changes
12
+
13
+ - feat(client): add tRPC router type support for ClientFromRouter and VeloxHooks
14
+
3
15
  ## 0.6.93
4
16
 
5
17
  ### Patch Changes
@@ -69,7 +69,7 @@ function generateHealthSchema() {
69
69
  return compileTemplate('api/schemas/health.ts', AUTH_CONFIG);
70
70
  }
71
71
  function generateApiTypesTs() {
72
- return compileTemplate('api/types.ts', AUTH_CONFIG);
72
+ return compileTemplate('api/types.auth.ts', AUTH_CONFIG);
73
73
  }
74
74
  function generateAuthUtils() {
75
75
  return compileTemplate('api/utils/auth.ts', AUTH_CONFIG);
@@ -91,10 +91,18 @@ export declare const CONDITIONALS: {
91
91
  readonly AUTH_END: "/* @endif auth */";
92
92
  readonly DEFAULT_START: "/* @if default */";
93
93
  readonly DEFAULT_END: "/* @endif default */";
94
+ readonly TRPC_START: "/* @if trpc */";
95
+ readonly TRPC_END: "/* @endif trpc */";
96
+ readonly REST_START: "/* @if rest */";
97
+ readonly REST_END: "/* @endif rest */";
94
98
  readonly JSX_AUTH_START: "{/* @if auth */}";
95
99
  readonly JSX_AUTH_END: "{/* @endif auth */}";
96
100
  readonly JSX_DEFAULT_START: "{/* @if default */}";
97
101
  readonly JSX_DEFAULT_END: "{/* @endif default */}";
102
+ readonly JSX_TRPC_START: "{/* @if trpc */}";
103
+ readonly JSX_TRPC_END: "{/* @endif trpc */}";
104
+ readonly JSX_REST_START: "{/* @if rest */}";
105
+ readonly JSX_REST_END: "{/* @endif rest */}";
98
106
  readonly SQLITE_START: "/* @if sqlite */";
99
107
  readonly SQLITE_END: "/* @endif sqlite */";
100
108
  readonly POSTGRESQL_START: "/* @if postgresql */";
@@ -250,11 +250,19 @@ export const CONDITIONALS = {
250
250
  AUTH_END: '/* @endif auth */',
251
251
  DEFAULT_START: '/* @if default */',
252
252
  DEFAULT_END: '/* @endif default */',
253
+ TRPC_START: '/* @if trpc */',
254
+ TRPC_END: '/* @endif trpc */',
255
+ REST_START: '/* @if rest */',
256
+ REST_END: '/* @endif rest */',
253
257
  // JSX-style template conditionals (wrapped in braces)
254
258
  JSX_AUTH_START: '{/* @if auth */}',
255
259
  JSX_AUTH_END: '{/* @endif auth */}',
256
260
  JSX_DEFAULT_START: '{/* @if default */}',
257
261
  JSX_DEFAULT_END: '{/* @endif default */}',
262
+ JSX_TRPC_START: '{/* @if trpc */}',
263
+ JSX_TRPC_END: '{/* @endif trpc */}',
264
+ JSX_REST_START: '{/* @if rest */}',
265
+ JSX_REST_END: '{/* @endif rest */}',
258
266
  // Database conditionals
259
267
  SQLITE_START: '/* @if sqlite */',
260
268
  SQLITE_END: '/* @endif sqlite */',
@@ -274,6 +282,14 @@ const DEFAULT_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.DEFAULT_STA
274
282
  const JSX_AUTH_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.JSX_AUTH_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.JSX_AUTH_END)}`, 'g');
275
283
  /** Pre-compiled regex for JSX default conditional blocks */
276
284
  const JSX_DEFAULT_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.JSX_DEFAULT_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.JSX_DEFAULT_END)}`, 'g');
285
+ /** Pre-compiled regex for trpc conditional blocks */
286
+ const TRPC_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.TRPC_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.TRPC_END)}`, 'g');
287
+ /** Pre-compiled regex for JSX trpc conditional blocks */
288
+ const JSX_TRPC_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.JSX_TRPC_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.JSX_TRPC_END)}`, 'g');
289
+ /** Pre-compiled regex for rest conditional blocks (all templates except trpc) */
290
+ const REST_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.REST_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.REST_END)}`, 'g');
291
+ /** Pre-compiled regex for JSX rest conditional blocks */
292
+ const JSX_REST_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.JSX_REST_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.JSX_REST_END)}`, 'g');
277
293
  /** Pre-compiled regex for sqlite conditional blocks */
278
294
  const SQLITE_BLOCK_PATTERN = new RegExp(`${escapeRegex(CONDITIONALS.SQLITE_START)}[\\s\\S]*?${escapeRegex(CONDITIONALS.SQLITE_END)}`, 'g');
279
295
  /** Pre-compiled regex for postgresql conditional blocks */
@@ -309,8 +325,9 @@ export function processConditionals(content, config) {
309
325
  result = result.replace(JSX_AUTH_BLOCK_PATTERN, '');
310
326
  }
311
327
  // Process default conditionals (both JS and JSX style)
312
- // Note: 'trpc' and 'rsc' templates use default-style content (no auth)
313
- if (template === 'spa' || template === 'trpc' || template === 'rsc') {
328
+ // Note: 'rsc' template uses default-style content (no auth)
329
+ // 'trpc' template has its own @if trpc blocks for tRPC-specific configuration
330
+ if (template === 'spa' || template === 'rsc') {
314
331
  // Keep default content but remove markers
315
332
  result = result.replaceAll(CONDITIONALS.DEFAULT_START, '');
316
333
  result = result.replaceAll(CONDITIONALS.DEFAULT_END, '');
@@ -318,10 +335,37 @@ export function processConditionals(content, config) {
318
335
  result = result.replaceAll(CONDITIONALS.JSX_DEFAULT_END, '');
319
336
  }
320
337
  else {
321
- // Remove entire default blocks (for auth template)
338
+ // Remove entire default blocks (for auth and trpc templates)
322
339
  result = result.replace(DEFAULT_BLOCK_PATTERN, '');
323
340
  result = result.replace(JSX_DEFAULT_BLOCK_PATTERN, '');
324
341
  }
342
+ // Process trpc conditionals (both JS and JSX style)
343
+ if (template === 'trpc') {
344
+ // Keep trpc content but remove markers
345
+ result = result.replaceAll(CONDITIONALS.TRPC_START, '');
346
+ result = result.replaceAll(CONDITIONALS.TRPC_END, '');
347
+ result = result.replaceAll(CONDITIONALS.JSX_TRPC_START, '');
348
+ result = result.replaceAll(CONDITIONALS.JSX_TRPC_END, '');
349
+ }
350
+ else {
351
+ // Remove entire trpc blocks (for spa, auth, rsc templates)
352
+ result = result.replace(TRPC_BLOCK_PATTERN, '');
353
+ result = result.replace(JSX_TRPC_BLOCK_PATTERN, '');
354
+ }
355
+ // Process rest conditionals (both JS and JSX style)
356
+ // REST mode applies to all templates except trpc (spa, auth, rsc)
357
+ if (template !== 'trpc') {
358
+ // Keep rest content but remove markers
359
+ result = result.replaceAll(CONDITIONALS.REST_START, '');
360
+ result = result.replaceAll(CONDITIONALS.REST_END, '');
361
+ result = result.replaceAll(CONDITIONALS.JSX_REST_START, '');
362
+ result = result.replaceAll(CONDITIONALS.JSX_REST_END, '');
363
+ }
364
+ else {
365
+ // Remove entire rest blocks (for trpc template)
366
+ result = result.replace(REST_BLOCK_PATTERN, '');
367
+ result = result.replace(JSX_REST_BLOCK_PATTERN, '');
368
+ }
325
369
  // =========================================================================
326
370
  // Database conditionals
327
371
  // =========================================================================
@@ -57,7 +57,7 @@ function generateHealthSchema() {
57
57
  return compileTemplate('api/schemas/health.ts', DEFAULT_CONFIG);
58
58
  }
59
59
  function generateApiTypesTs() {
60
- return compileTemplate('api/types.ts', DEFAULT_CONFIG);
60
+ return compileTemplate('api/types.default.ts', DEFAULT_CONFIG);
61
61
  }
62
62
  function generateDockerCompose(config) {
63
63
  return compileTemplate('api/docker-compose.yml', config);
@@ -19,8 +19,8 @@ import { generateRootFiles, generateWebBaseFiles, generateWebStyleFiles } from '
19
19
  // API Template Compilation
20
20
  // ============================================================================
21
21
  function generateApiPackageJson(config) {
22
- // Reuse default package.json - @veloxts/velox already includes tRPC utilities
23
- const content = compileTemplate('api/package.default.json', config);
22
+ // Use tRPC package.json with @trpc/server for TypeScript type portability
23
+ const content = compileTemplate('api/package.trpc.json', config);
24
24
  return applyDatabaseDependencies(content, config);
25
25
  }
26
26
  function generateApiTsConfig() {
@@ -67,7 +67,7 @@ function generateHealthSchema() {
67
67
  return compileTemplate('api/schemas/health.ts', DEFAULT_CONFIG);
68
68
  }
69
69
  function generateApiTypesTs() {
70
- return compileTemplate('api/types.ts', DEFAULT_CONFIG);
70
+ return compileTemplate('api/types.default.ts', DEFAULT_CONFIG);
71
71
  }
72
72
  function generateDockerCompose(config) {
73
73
  return compileTemplate('api/docker-compose.yml', config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-velox-app",
3
- "version": "0.6.93",
3
+ "version": "0.6.95",
4
4
  "description": "Project scaffolder for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "api",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "scripts": {
8
+ "build": "tsup",
9
+ "start": "node dist/index.js",
10
+ "dev": "tsx watch src/index.ts",
11
+ "dev:hmr": "velox dev --hmr",
12
+ "type-check": "prisma generate && tsc --noEmit",
13
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});require('fs').rmSync('tsconfig.tsbuildinfo',{force:true})\"",
14
+ "db:generate": "prisma generate",
15
+ "db:push": "prisma db push",
16
+ "db:seed": "prisma db seed",
17
+ "db:studio": "prisma studio",
18
+ "postinstall": "prisma generate"
19
+ },
20
+ "dependencies": {
21
+ "@prisma/adapter-better-sqlite3": "7.3.0",
22
+ "@prisma/client": "7.3.0",
23
+ "@prisma/client-runtime-utils": "7.3.0",
24
+ "@trpc/server": "11.9.0",
25
+ "@veloxts/core": "__VELOXTS_VERSION__",
26
+ "@veloxts/velox": "__VELOXTS_VERSION__",
27
+ "better-sqlite3": "12.6.2",
28
+ "dotenv": "17.2.3",
29
+ "file-uri-to-path": "2.0.0",
30
+ "zod": "3.25.76"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "25.1.0",
34
+ "hot-hook": "0.4.0",
35
+ "prisma": "7.3.0",
36
+ "tsup": "8.5.1",
37
+ "tsx": "4.21.0",
38
+ "typescript": "5.9.3"
39
+ },
40
+ "hotHook": {
41
+ "boundaries": ["./src/procedures/**/*.ts", "./src/schemas/**/*.ts", "./src/handlers/**/*.ts"]
42
+ }
43
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Type declarations for VeloxTS application
3
+ *
4
+ * This file uses declaration merging to extend the framework's base types
5
+ * with application-specific properties:
6
+ *
7
+ * - `ctx.db`: Typed PrismaClient for database access in procedure handlers
8
+ *
9
+ * IMPORTANT: This file must be imported (side-effect import) in your entry
10
+ * point to ensure the declaration merging is processed by TypeScript.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // In your index.ts entry point:
15
+ * import './types.js'; // Side-effect import for declaration merging
16
+ * ```
17
+ */
18
+
19
+ import type { PrismaClient } from '@prisma/client';
20
+
21
+ declare module '@veloxts/core' {
22
+ interface BaseContext {
23
+ db: PrismaClient;
24
+ }
25
+ }
@@ -72,6 +72,11 @@ createRoot(rootElement).render(
72
72
  <RouterProvider router={router} />
73
73
  </VeloxProvider>
74
74
  {/* @endif default */}
75
+ {/* @if trpc */}
76
+ <VeloxProvider<AppRouter> config={{ baseUrl: '/trpc' }}>
77
+ <RouterProvider router={router} />
78
+ </VeloxProvider>
79
+ {/* @endif trpc */}
75
80
  {/* @if auth */}
76
81
  <VeloxProvider<AppRouter>
77
82
  config={{
@@ -14,10 +14,18 @@ export default defineConfig({
14
14
  server: {
15
15
  port: __WEB_PORT__,
16
16
  proxy: {
17
+ /* @if trpc */
18
+ '/trpc': {
19
+ target: 'http://localhost:__API_PORT__',
20
+ changeOrigin: true,
21
+ },
22
+ /* @endif trpc */
23
+ /* @if rest */
17
24
  '/api': {
18
25
  target: 'http://localhost:__API_PORT__',
19
26
  changeOrigin: true,
20
27
  },
28
+ /* @endif rest */
21
29
  },
22
30
  },
23
31
  });