create-velox-app 0.6.83 → 0.6.85

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.85
4
+
5
+ ### Patch Changes
6
+
7
+ - implement missing features from original requirements
8
+
9
+ ## 0.6.84
10
+
11
+ ### Patch Changes
12
+
13
+ - - auth: add simplified guard() function with overloads + fluent builder
14
+
3
15
  ## 0.6.83
4
16
 
5
17
  ### Patch Changes
@@ -1,14 +1,16 @@
1
1
  /**
2
- * tRPC Hybrid Template (Full-Stack)
2
+ * tRPC Template (Full-Stack)
3
3
  *
4
4
  * Full-stack workspace template with:
5
- * - apps/api: Hybrid tRPC + REST API with user CRUD operations
5
+ * - apps/api: tRPC-only API with user CRUD operations
6
6
  * - apps/web: React frontend with TanStack Router
7
7
  *
8
8
  * Showcases VeloxTS's type-safe frontend-backend communication:
9
- * - tRPC endpoints for internal consumption (primary)
10
- * - REST endpoints for external APIs (auto-generated)
9
+ * - tRPC endpoints only (no REST)
11
10
  * - End-to-end type safety without code generation
11
+ * - Frontend imports types directly from router.ts
12
+ *
13
+ * For REST + tRPC hybrid, use --default template and add registerRpc().
12
14
  */
13
15
  import type { TemplateConfig, TemplateFile } from './types.js';
14
16
  export declare function generateTrpcTemplate(config: TemplateConfig): TemplateFile[];
@@ -1,14 +1,16 @@
1
1
  /**
2
- * tRPC Hybrid Template (Full-Stack)
2
+ * tRPC Template (Full-Stack)
3
3
  *
4
4
  * Full-stack workspace template with:
5
- * - apps/api: Hybrid tRPC + REST API with user CRUD operations
5
+ * - apps/api: tRPC-only API with user CRUD operations
6
6
  * - apps/web: React frontend with TanStack Router
7
7
  *
8
8
  * Showcases VeloxTS's type-safe frontend-backend communication:
9
- * - tRPC endpoints for internal consumption (primary)
10
- * - REST endpoints for external APIs (auto-generated)
9
+ * - tRPC endpoints only (no REST)
11
10
  * - End-to-end type safety without code generation
11
+ * - Frontend imports types directly from router.ts
12
+ *
13
+ * For REST + tRPC hybrid, use --default template and add registerRpc().
12
14
  */
13
15
  import { compileTemplate } from './compiler.js';
14
16
  import { applyDatabaseDependencies, DEFAULT_CONFIG, TRPC_CONFIG } from './placeholders.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-velox-app",
3
- "version": "0.6.83",
3
+ "version": "0.6.85",
4
4
  "description": "Project scaffolder for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Application Entry Point - tRPC Hybrid Template
2
+ * Application Entry Point - tRPC Template
3
3
  *
4
- * VeloxTS hybrid API architecture:
4
+ * VeloxTS tRPC-only API architecture:
5
5
  * - tRPC at /trpc for type-safe frontend communication
6
- * - REST at /api for external consumers
6
+ * - No REST endpoints (use --default template for REST)
7
7
  *
8
- * Both APIs generated from the same procedure definitions.
8
+ * Frontend imports types directly from router.ts for full type safety.
9
9
  */
10
10
 
11
11
  import 'dotenv/config';
@@ -13,15 +13,13 @@ import 'dotenv/config';
13
13
  // Side-effect import for declaration merging (extends ctx.db type)
14
14
  import './types.js';
15
15
 
16
- import { databasePlugin, serve, veloxApp } from '@veloxts/velox';
16
+ import { databasePlugin, registerRpc, veloxApp } from '@veloxts/velox';
17
17
 
18
18
  import { config } from './config/app.js';
19
19
  import { db } from './config/database.js';
20
- // Import router definition (type-only safe for frontend imports)
21
20
  import { collections } from './router.js';
22
21
 
23
- // Re-export AppRouter for backward compatibility
24
- // Frontend should import from ./router.js directly for type safety
22
+ // Re-export AppRouter for frontend type imports
25
23
  export type { AppRouter } from './router.js';
26
24
 
27
25
  // ============================================================================
@@ -37,19 +35,18 @@ const app = await veloxApp({
37
35
  await app.register(databasePlugin({ client: db }));
38
36
 
39
37
  // ============================================================================
40
- // API Registration
38
+ // tRPC Registration
41
39
  // ============================================================================
42
40
 
43
41
  /**
44
- * Serve procedures as both REST and tRPC endpoints
42
+ * Register tRPC routes at /trpc
45
43
  *
46
- * - REST: /api/users, /api/health
47
- * - tRPC: /trpc/users.getUser, /trpc/health.getHealth
44
+ * Endpoints: /trpc/users.listUsers, /trpc/health.getHealth, etc.
45
+ *
46
+ * No REST endpoints - this template is for internal TypeScript clients only.
47
+ * For REST + tRPC hybrid, use the --default template and add registerRpc().
48
48
  */
49
- await serve(app, collections, {
50
- api: config.apiPrefix,
51
- rpc: '/trpc',
52
- });
49
+ await registerRpc(app, collections, { prefix: '/trpc' });
53
50
 
54
51
  await app.start();
55
52
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Router Definition - tRPC Hybrid Template
3
3
  *
4
- * This file exports the router type for frontend type safety.
4
+ * This file exports the typed tRPC router for frontend type safety.
5
5
  * It MUST NOT have any side effects (like importing dotenv) so that
6
6
  * the frontend can safely import types from here.
7
7
  *
@@ -14,26 +14,52 @@
14
14
  // This is NOT a runtime import - it only affects type checking.
15
15
  /// <reference path="./types.ts" />
16
16
 
17
- import { createRouter } from '@veloxts/velox';
17
+ import { rpc } from '@veloxts/velox';
18
18
 
19
19
  import { healthProcedures } from './procedures/health.js';
20
20
  import { userProcedures } from './procedures/users.js';
21
21
 
22
- // Create router and collections from procedure definitions
23
- export const { collections, router } = createRouter(healthProcedures, userProcedures);
22
+ /**
23
+ * Procedure collections for REST and tRPC registration
24
+ *
25
+ * IMPORTANT: Use `as const` to preserve literal types for full type inference.
26
+ */
27
+ export const collections = [healthProcedures, userProcedures] as const;
28
+
29
+ /**
30
+ * Create typed tRPC router using the rpc() helper
31
+ *
32
+ * The rpc() helper returns:
33
+ * - `router`: Fully typed tRPC router for client type inference
34
+ * - `register`: Async function to register tRPC routes with Fastify
35
+ *
36
+ * NOTE: `register` is not exported to avoid TypeScript portability issues.
37
+ * Use registerRpc() in index.ts instead.
38
+ */
39
+ const { router } = rpc(collections, { prefix: '/trpc' });
40
+
41
+ /**
42
+ * Typed tRPC router for client imports
43
+ *
44
+ * Use this for type-safe frontend-backend communication.
45
+ */
46
+ export { router };
24
47
 
25
48
  /**
26
49
  * AppRouter type for frontend type safety
27
50
  *
28
- * Constructed from procedure collections to preserve full type information.
29
- * This enables type-safe API calls with full autocomplete.
51
+ * This is the properly typed tRPC router that enables:
52
+ * - Full autocomplete for procedure names
53
+ * - Type-safe input validation
54
+ * - Inferred output types
30
55
  *
31
56
  * @example
32
57
  * ```typescript
33
58
  * import type { AppRouter } from '../../api/src/router.js';
34
- * import { createVeloxHooks } from '@veloxts/client/react';
59
+ * import { createTRPCClient } from '@trpc/client';
35
60
  *
36
- * export const api = createVeloxHooks<AppRouter>();
61
+ * const client = createTRPCClient<AppRouter>({ links: [...] });
62
+ * const users = await client.users.listUsers.query(); // Fully typed!
37
63
  * ```
38
64
  */
39
65
  export type AppRouter = typeof router;