@idealyst/cli 1.0.45 → 1.0.48

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 (121) hide show
  1. package/dist/generators/fullstack.js +61 -3
  2. package/dist/generators/fullstack.js.map +1 -1
  3. package/dist/generators/native.js +12 -0
  4. package/dist/generators/native.js.map +1 -1
  5. package/dist/generators/utils.js +64 -31
  6. package/dist/generators/utils.js.map +1 -1
  7. package/dist/templates/api/README.md +207 -130
  8. package/dist/templates/api/package.json +5 -5
  9. package/dist/templates/api/src/controllers/TestController.ts +0 -0
  10. package/dist/templates/api/src/index.ts +2 -7
  11. package/dist/templates/api/src/lib/crud.ts +150 -0
  12. package/dist/templates/api/src/lib/database.ts +23 -0
  13. package/dist/templates/api/src/router/index.ts +104 -71
  14. package/dist/templates/api/src/routers/test.ts +59 -0
  15. package/dist/templates/api/src/routers/user.example.ts +83 -0
  16. package/dist/templates/api/src/server.ts +1 -1
  17. package/dist/templates/api/tsconfig.json +0 -1
  18. package/dist/templates/database/README.md +115 -1
  19. package/dist/templates/database/package.json +2 -0
  20. package/dist/templates/database/prisma/seed.ts +37 -1
  21. package/dist/templates/database/schema.prisma +11 -1
  22. package/dist/templates/native/index.js +1 -1
  23. package/dist/templates/native/metro.config.js +1 -1
  24. package/dist/templates/native/package.json +4 -0
  25. package/dist/templates/native/src/App.tsx +16 -0
  26. package/dist/templates/native/src/utils/trpc.ts +7 -127
  27. package/dist/templates/native/tsconfig.json +0 -2
  28. package/dist/templates/shared/README.md +31 -5
  29. package/dist/templates/shared/__tests__/shared.test.ts +17 -5
  30. package/dist/templates/shared/package.json +14 -30
  31. package/dist/templates/shared/src/components/App.tsx +57 -0
  32. package/dist/templates/shared/src/components/HelloWorld.tsx +307 -0
  33. package/dist/templates/shared/src/components/index.ts +1 -392
  34. package/dist/templates/shared/src/index.ts +9 -57
  35. package/dist/templates/shared/src/trpc/client.ts +39 -0
  36. package/dist/templates/shared/tsconfig.json +4 -7
  37. package/dist/templates/web/README.md +65 -8
  38. package/dist/templates/web/package.json +3 -3
  39. package/dist/templates/web/src/App-with-trpc-and-shared.tsx +11 -299
  40. package/dist/templates/web/src/components/TestDemo.tsx +164 -0
  41. package/dist/templates/web/src/utils/trpc.ts +7 -93
  42. package/dist/templates/web/tsconfig.json +0 -1
  43. package/dist/templates/workspace/.devcontainer/devcontainer.json +4 -9
  44. package/dist/templates/workspace/.devcontainer/docker-compose.yml +1 -2
  45. package/dist/templates/workspace/.devcontainer/setup.sh +1 -1
  46. package/dist/templates/workspace/.env.example +1 -1
  47. package/dist/templates/workspace/Dockerfile +4 -4
  48. package/dist/templates/workspace/docker/nginx/prod.conf +2 -2
  49. package/dist/templates/workspace/docker/nginx.conf +1 -1
  50. package/dist/templates/workspace/docker/prometheus/prometheus.yml +1 -1
  51. package/dist/templates/workspace/docker-compose.yml +4 -5
  52. package/dist/templates/workspace/tsconfig.json +0 -1
  53. package/package.json +1 -1
  54. package/templates/api/README.md +207 -130
  55. package/templates/api/package.json +5 -5
  56. package/templates/api/src/controllers/TestController.ts +0 -0
  57. package/templates/api/src/index.ts +2 -7
  58. package/templates/api/src/lib/crud.ts +150 -0
  59. package/templates/api/src/lib/database.ts +23 -0
  60. package/templates/api/src/router/index.ts +104 -71
  61. package/templates/api/src/routers/test.ts +59 -0
  62. package/templates/api/src/routers/user.example.ts +83 -0
  63. package/templates/api/src/server.ts +1 -1
  64. package/templates/api/tsconfig.json +0 -1
  65. package/templates/database/README.md +115 -1
  66. package/templates/database/package.json +2 -0
  67. package/templates/database/prisma/seed.ts +37 -1
  68. package/templates/database/schema.prisma +11 -1
  69. package/templates/native/index.js +1 -1
  70. package/templates/native/metro.config.js +1 -1
  71. package/templates/native/package.json +4 -0
  72. package/templates/native/src/App.tsx +16 -0
  73. package/templates/native/src/utils/trpc.ts +7 -127
  74. package/templates/native/tsconfig.json +0 -2
  75. package/templates/shared/README.md +31 -5
  76. package/templates/shared/__tests__/shared.test.ts +17 -5
  77. package/templates/shared/package.json +14 -30
  78. package/templates/shared/src/components/App.tsx +57 -0
  79. package/templates/shared/src/components/HelloWorld.tsx +307 -0
  80. package/templates/shared/src/components/index.ts +1 -392
  81. package/templates/shared/src/index.ts +9 -57
  82. package/templates/shared/src/trpc/client.ts +39 -0
  83. package/templates/shared/tsconfig.json +4 -7
  84. package/templates/web/README.md +65 -8
  85. package/templates/web/package.json +3 -3
  86. package/templates/web/src/App-with-trpc-and-shared.tsx +11 -299
  87. package/templates/web/src/components/TestDemo.tsx +164 -0
  88. package/templates/web/src/utils/trpc.ts +7 -93
  89. package/templates/web/tsconfig.json +0 -1
  90. package/templates/workspace/.devcontainer/devcontainer.json +4 -9
  91. package/templates/workspace/.devcontainer/docker-compose.yml +1 -2
  92. package/templates/workspace/.devcontainer/setup.sh +1 -1
  93. package/templates/workspace/.env.example +1 -1
  94. package/templates/workspace/Dockerfile +4 -4
  95. package/templates/workspace/docker/nginx/prod.conf +2 -2
  96. package/templates/workspace/docker/nginx.conf +1 -1
  97. package/templates/workspace/docker/prometheus/prometheus.yml +1 -1
  98. package/templates/workspace/docker-compose.yml +4 -5
  99. package/templates/workspace/tsconfig.json +0 -1
  100. package/dist/templates/api/src/controllers/UserController.ts +0 -102
  101. package/dist/templates/api/src/lib/controller.ts +0 -90
  102. package/dist/templates/api/src/lib/middleware.ts +0 -170
  103. package/dist/templates/api/src/middleware/auth.ts +0 -75
  104. package/dist/templates/api/src/middleware/common.ts +0 -103
  105. package/dist/templates/database/.env.example +0 -1
  106. package/dist/templates/native/App.tsx +0 -23
  107. package/dist/templates/native/src/App-with-trpc-and-shared.tsx +0 -266
  108. package/dist/templates/shared/rollup.config.js +0 -43
  109. package/dist/templates/shared/src/types/index.ts +0 -148
  110. package/dist/templates/shared/src/utils/index.ts +0 -278
  111. package/templates/api/src/controllers/UserController.ts +0 -102
  112. package/templates/api/src/lib/controller.ts +0 -90
  113. package/templates/api/src/lib/middleware.ts +0 -170
  114. package/templates/api/src/middleware/auth.ts +0 -75
  115. package/templates/api/src/middleware/common.ts +0 -103
  116. package/templates/database/.env.example +0 -1
  117. package/templates/native/App.tsx +0 -23
  118. package/templates/native/src/App-with-trpc-and-shared.tsx +0 -266
  119. package/templates/shared/rollup.config.js +0 -43
  120. package/templates/shared/src/types/index.ts +0 -148
  121. package/templates/shared/src/utils/index.ts +0 -278
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { router, publicProcedure } from '../trpc.js';
3
+ import { testRouter } from '../routers/test.js';
3
4
 
4
5
  export const appRouter = router({
5
6
  // Simple hello world procedure
@@ -21,110 +22,142 @@ export const appRouter = router({
21
22
  };
22
23
  }),
23
24
 
24
- // Add your procedures here
25
+ // Test CRUD endpoints - generated automatically from Prisma model
26
+ test: testRouter,
27
+
28
+ // Add your model routers here
25
29
  // Example:
26
30
  // users: userRouter,
27
31
  // posts: postRouter,
28
-
29
- // Example controller integration:
30
- // Uncomment the lines below and create the corresponding controllers
31
-
32
- // 1. Import your controllers at the top:
33
- // import { userRouter } from '../controllers/UserController.js';
34
-
35
- // 2. Add them to the router:
36
- // users: userRouter,
37
32
  });
38
33
 
39
34
  // Export type definition of API
40
35
  export type AppRouter = typeof appRouter;
41
36
 
42
37
  /*
43
- CONTROLLER & MIDDLEWARE SYSTEM USAGE:
38
+ SIMPLIFIED CRUD API SYSTEM:
44
39
 
45
- This API template includes a controller and middleware system that works seamlessly with tRPC.
40
+ This API template uses a simplified approach with automatic CRUD generation for Prisma models.
46
41
 
47
- ## Quick Start with Controllers:
42
+ ## Quick Start:
48
43
 
49
- 1. Create a controller (see src/controllers/UserController.ts for example):
44
+ 1. **Define your Prisma model** in packages/database/schema.prisma
45
+ 2. **Create Zod schemas** for validation
46
+ 3. **Generate CRUD router** using createCrudRouter()
47
+ 4. **Add to main router**
48
+
49
+ ## Example - Adding a User model:
50
+
51
+ ### 1. Define Prisma model:
52
+ ```prisma
53
+ model User {
54
+ id String @id @default(cuid())
55
+ email String @unique
56
+ name String
57
+ createdAt DateTime @default(now())
58
+ updatedAt DateTime @updatedAt
59
+ }
60
+ ```
50
61
 
62
+ ### 2. Create router file (src/routers/user.ts):
51
63
  ```typescript
52
64
  import { z } from 'zod';
53
- import { BaseController, controllerToRouter } from '../lib/controller.js';
54
- import { requireAuth } from '../middleware/auth.js';
55
-
56
- export class UserController extends BaseController {
57
- getAll = this.createQueryWithMiddleware(
58
- z.object({}),
59
- [requireAuth],
60
- async (input, ctx) => {
61
- return await ctx.prisma.user.findMany();
62
- }
63
- );
64
- }
65
+ import { createCrudRouter } from '../lib/crud.js';
65
66
 
66
- export const userRouter = controllerToRouter({
67
- getAll: new UserController({} as any).getAll,
67
+ const createUserSchema = z.object({
68
+ email: z.string().email(),
69
+ name: z.string().min(1),
68
70
  });
69
- ```
70
71
 
71
- 2. Add to main router:
72
+ const updateUserSchema = z.object({
73
+ email: z.string().email().optional(),
74
+ name: z.string().min(1).optional(),
75
+ });
72
76
 
77
+ export const userRouter = createCrudRouter(
78
+ 'user',
79
+ createUserSchema,
80
+ updateUserSchema
81
+ );
82
+ ```
83
+
84
+ ### 3. Add to main router:
73
85
  ```typescript
74
- import { userRouter } from '../controllers/UserController.js';
86
+ import { userRouter } from '../routers/user.js';
75
87
 
76
88
  export const appRouter = router({
77
- users: userRouter,
78
89
  // ... other routes
90
+ users: userRouter,
91
+ });
92
+ ```
93
+
94
+ ### 4. Use in frontend:
95
+ ```typescript
96
+ // Get all users
97
+ const { data: users } = trpc.users.getAll.useQuery();
98
+
99
+ // Create user
100
+ const createUser = trpc.users.create.useMutation();
101
+ await createUser.mutateAsync({
102
+ email: 'user@example.com',
103
+ name: 'John Doe'
104
+ });
105
+
106
+ // Update user
107
+ const updateUser = trpc.users.update.useMutation();
108
+ await updateUser.mutateAsync({
109
+ id: 'user-id',
110
+ data: { name: 'Jane Doe' }
79
111
  });
80
112
  ```
81
113
 
82
- ## Available Middleware:
114
+ ## Available CRUD Operations:
83
115
 
84
- ### Authentication:
85
- - `requireAuth` - Requires Bearer token
86
- - `requireRole(role)` - Requires specific role
87
- - `requireAdmin` - Requires admin role
116
+ Each generated router includes:
117
+ - `getAll({ skip?, take?, orderBy? })` - List with pagination
118
+ - `getById({ id })` - Get single record
119
+ - `create(data)` - Create new record
120
+ - `update({ id, data })` - Update existing record
121
+ - `delete({ id })` - Delete record
122
+ - `count({ where? })` - Count records
88
123
 
89
- ### Utility:
90
- - `logger` - Request/response logging
91
- - `rateLimit(max, window)` - Rate limiting
92
- - `responseTime` - Adds response time header
93
- - `requestId` - Adds unique request ID
94
- - `errorHandler` - Centralized error handling
124
+ ## Advanced Usage:
95
125
 
96
- ## Usage Examples:
126
+ ### Custom procedures:
127
+ You can extend generated routers with custom procedures:
97
128
 
98
129
  ```typescript
99
- // Public endpoint
100
- getPublicData = this.createQuery(schema, handler);
101
-
102
- // Protected endpoint
103
- getPrivateData = this.createQueryWithMiddleware(
104
- schema,
105
- [requireAuth],
106
- handler
107
- );
130
+ import { z } from 'zod';
131
+ import { router, publicProcedure } from '../trpc.js';
132
+ import { createCrudRouter } from '../lib/crud.js';
133
+ import { prisma } from '../lib/database.js';
108
134
 
109
- // Admin-only endpoint
110
- adminAction = this.createMutationWithMiddleware(
111
- schema,
112
- [requireAuth, requireAdmin],
113
- handler
114
- );
135
+ const baseCrudRouter = createCrudRouter('user', createUserSchema);
115
136
 
116
- // Multiple middleware
117
- complexEndpoint = this.createQueryWithMiddleware(
118
- schema,
119
- [logger, rateLimit(10, 60000), requireAuth],
120
- handler
121
- );
137
+ export const userRouter = router({
138
+ ...baseCrudRouter,
139
+
140
+ // Add custom procedures
141
+ getByEmail: publicProcedure
142
+ .input(z.object({ email: z.string().email() }))
143
+ .query(async ({ input }) => {
144
+ return await prisma.user.findUnique({
145
+ where: { email: input.email }
146
+ });
147
+ }),
148
+ });
149
+ ```
150
+
151
+ ### Authentication & Authorization:
152
+ Use middleware for protected procedures:
153
+
154
+ ```typescript
155
+ import { protectedProcedure } from '../trpc.js';
156
+
157
+ // Replace publicProcedure with protectedProcedure in createCrudRouter
158
+ // or create a custom version for authenticated routes
122
159
  ```
123
160
 
124
- This system provides:
125
- Type safety with tRPC
126
- ✅ Reusable middleware
127
- ✅ Clean controller organization
128
- ✅ Easy testing
129
- ✅ Consistent error handling
161
+ This simplified system removes the controller layer complexity while providing
162
+ type-safe, validated CRUD operations for all your Prisma models.
130
163
  */
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { createCrudRouter } from "../lib/crud.js";
3
+
4
+ // Define Zod schemas for the Test model based on the Prisma schema
5
+ const createTestSchema = z.object({
6
+ name: z.string().min(1, "Name is required"),
7
+ message: z.string().min(1, "Message is required"),
8
+ status: z.string().optional().default("active"),
9
+ });
10
+
11
+ const updateTestSchema = z.object({
12
+ name: z.string().min(1, "Name is required").optional(),
13
+ message: z.string().min(1, "Message is required").optional(),
14
+ status: z.string().optional(),
15
+ });
16
+
17
+ // Create the CRUD router for the Test model
18
+ export const testRouter = createCrudRouter(
19
+ "Test",
20
+ createTestSchema,
21
+ updateTestSchema
22
+ );
23
+
24
+ /**
25
+ * This generates the following endpoints:
26
+ *
27
+ * - test.getAll({ skip?, take?, orderBy? }) - Get all test records with pagination
28
+ * - test.getById({ id }) - Get test record by ID
29
+ * - test.create({ name, message, status? }) - Create new test record
30
+ * - test.update({ id, data: { name?, message?, status? } }) - Update test record
31
+ * - test.delete({ id }) - Delete test record
32
+ * - test.count({ where? }) - Get test record count
33
+ *
34
+ * Example usage in frontend:
35
+ *
36
+ * ```typescript
37
+ * // Get all tests
38
+ * const { data: tests } = trpc.test.getAll.useQuery({ take: 10 });
39
+ *
40
+ * // Create a new test
41
+ * const createTest = trpc.test.create.useMutation();
42
+ * await createTest.mutateAsync({
43
+ * name: 'My Test',
44
+ * message: 'This is a test message',
45
+ * status: 'active'
46
+ * });
47
+ *
48
+ * // Update a test
49
+ * const updateTest = trpc.test.update.useMutation();
50
+ * await updateTest.mutateAsync({
51
+ * id: 'test-id',
52
+ * data: { name: 'Updated Test' }
53
+ * });
54
+ *
55
+ * // Delete a test
56
+ * const deleteTest = trpc.test.delete.useMutation();
57
+ * await deleteTest.mutateAsync({ id: 'test-id' });
58
+ * ```
59
+ */
@@ -0,0 +1,83 @@
1
+ import { z } from 'zod';
2
+ import { createCrudRouter } from '../lib/crud.js';
3
+
4
+ // Define Zod schemas for the User model
5
+ const createUserSchema = z.object({
6
+ email: z.string().email('Invalid email format'),
7
+ name: z.string().min(1, 'Name is required'),
8
+ });
9
+
10
+ const updateUserSchema = z.object({
11
+ email: z.string().email('Invalid email format').optional(),
12
+ name: z.string().min(1, 'Name is required').optional(),
13
+ });
14
+
15
+ // Create the CRUD router for the User model
16
+ export const userRouter = createCrudRouter(
17
+ 'user',
18
+ createUserSchema,
19
+ updateUserSchema
20
+ );
21
+
22
+ /**
23
+ * This generates the following endpoints:
24
+ *
25
+ * - users.getAll({ skip?, take?, orderBy? }) - Get all users with pagination
26
+ * - users.getById({ id }) - Get user by ID
27
+ * - users.create({ name, email }) - Create new user
28
+ * - users.update({ id, data: { name?, email? } }) - Update user
29
+ * - users.delete({ id }) - Delete user
30
+ * - users.count({ where? }) - Get user count
31
+ *
32
+ * To use this router:
33
+ *
34
+ * 1. First add a User model to your Prisma schema:
35
+ *
36
+ * ```prisma
37
+ * model User {
38
+ * id String @id @default(cuid())
39
+ * email String @unique
40
+ * name String
41
+ * createdAt DateTime @default(now())
42
+ * updatedAt DateTime @updatedAt
43
+ * }
44
+ * ```
45
+ *
46
+ * 2. Run `yarn db:migrate` to apply the schema changes
47
+ *
48
+ * 3. Uncomment the users router in src/router/index.ts:
49
+ *
50
+ * ```typescript
51
+ * import { userRouter } from '../routers/user.js';
52
+ *
53
+ * export const appRouter = router({
54
+ * // ... other routes
55
+ * users: userRouter,
56
+ * });
57
+ * ```
58
+ *
59
+ * 4. Use in your frontend:
60
+ *
61
+ * ```typescript
62
+ * // Get all users
63
+ * const { data: users } = trpc.users.getAll.useQuery({ take: 10 });
64
+ *
65
+ * // Create a new user
66
+ * const createUser = trpc.users.create.useMutation();
67
+ * await createUser.mutateAsync({
68
+ * name: 'John Doe',
69
+ * email: 'john@example.com'
70
+ * });
71
+ *
72
+ * // Update a user
73
+ * const updateUser = trpc.users.update.useMutation();
74
+ * await updateUser.mutateAsync({
75
+ * id: 'user-id',
76
+ * data: { name: 'Jane Doe' }
77
+ * });
78
+ *
79
+ * // Delete a user
80
+ * const deleteUser = trpc.users.delete.useMutation();
81
+ * await deleteUser.mutateAsync({ id: 'user-id' });
82
+ * ```
83
+ */
@@ -13,7 +13,7 @@ const PORT = process.env.PORT || 3000;
13
13
 
14
14
  // CORS configuration
15
15
  app.use(cors({
16
- origin: process.env.CORS_ORIGIN || 'http://localhost:3000',
16
+ origin: process.env.CORS_ORIGIN || 'http://localhost:5173',
17
17
  credentials: true,
18
18
  }));
19
19
 
@@ -2,7 +2,6 @@
2
2
  "compilerOptions": {
3
3
  "target": "ES2020",
4
4
  "module": "ESNext",
5
- "moduleResolution": "node",
6
5
  "allowSyntheticDefaultImports": true,
7
6
  "esModuleInterop": true,
8
7
  "allowJs": true,
@@ -1,6 +1,6 @@
1
1
  # Database Package
2
2
 
3
- This package provides database access and validation schemas for the workspace.
3
+ This package provides database access and validation schemas for the workspace using Prisma ORM.
4
4
 
5
5
  ## Setup
6
6
 
@@ -25,6 +25,120 @@ yarn db:generate
25
25
  yarn db:push
26
26
  ```
27
27
 
28
+ 5. Seed the database with test data:
29
+ ```bash
30
+ yarn db:seed
31
+ ```
32
+
33
+ ## Database Schema
34
+
35
+ ### Test Model
36
+
37
+ The Test model is included for quick testing and API demonstration:
38
+
39
+ ```prisma
40
+ model Test {
41
+ id String @id @default(cuid())
42
+ name String
43
+ message String
44
+ status String @default("active")
45
+ createdAt DateTime @default(now())
46
+ updatedAt DateTime @updatedAt
47
+ }
48
+ ```
49
+
50
+ #### Fields:
51
+ - `id`: Unique identifier (CUID)
52
+ - `name`: Test name/title
53
+ - `message`: Test message content
54
+ - `status`: Test status (defaults to "active")
55
+ - `createdAt`: Record creation timestamp
56
+ - `updatedAt`: Record last update timestamp
57
+
58
+ ### Sample Models
59
+
60
+ The schema also includes comprehensive example models for reference:
61
+
62
+ #### User Model
63
+ - Complete user management with authentication fields
64
+ - Email validation and profile information
65
+ - Timestamps for tracking
66
+
67
+ #### Post Model
68
+ - Blog post or content management
69
+ - User relationship for authorship
70
+ - Publishing status and timestamps
71
+
72
+ #### Comment Model
73
+ - Comment system for posts
74
+ - User and post relationships
75
+ - Moderation support
76
+
77
+ ## Usage
78
+
79
+ ### In API Code
80
+
81
+ ```typescript
82
+ import { db } from '@{{workspaceScope}}/database';
83
+
84
+ // Create a test record
85
+ const test = await db.test.create({
86
+ data: {
87
+ name: 'My Test',
88
+ message: 'This is a test message',
89
+ status: 'active'
90
+ }
91
+ });
92
+
93
+ // Get all tests
94
+ const tests = await db.test.findMany();
95
+
96
+ // Update a test
97
+ const updatedTest = await db.test.update({
98
+ where: { id: 'test-id' },
99
+ data: { status: 'completed' }
100
+ });
101
+ ```
102
+
103
+ ### Prisma Commands
104
+
105
+ ```bash
106
+ # Generate client
107
+ yarn prisma:generate
108
+
109
+ # Run migrations
110
+ yarn prisma:migrate
111
+
112
+ # Reset database
113
+ yarn prisma:reset
114
+
115
+ # Seed database
116
+ yarn prisma:seed
117
+
118
+ # Open Prisma Studio
119
+ yarn prisma:studio
120
+ ```
121
+
122
+ ## Quick Test
123
+
124
+ The database includes a simple `Test` model for immediate testing:
125
+
126
+ ```typescript
127
+ import { prisma } from '@{{workspaceScope}}/{{name}}';
128
+
129
+ // Get all test entries
130
+ const tests = await prisma.test.findMany();
131
+
132
+ // Create a new test entry
133
+ const newTest = await prisma.test.create({
134
+ data: {
135
+ name: 'My Test',
136
+ message: 'Testing the database connection',
137
+ status: 'active',
138
+ },
139
+ });
140
+ ```
141
+
28
142
  ## Usage
29
143
 
30
144
  ```typescript
@@ -28,6 +28,7 @@
28
28
  "db:push": "prisma db push",
29
29
  "db:migrate": "prisma migrate dev",
30
30
  "db:studio": "prisma studio",
31
+ "db:seed": "tsx prisma/seed.ts",
31
32
  "db:reset": "prisma migrate reset"
32
33
  },
33
34
  "dependencies": {
@@ -37,6 +38,7 @@
37
38
  "devDependencies": {
38
39
  "@types/node": "^20.10.0",
39
40
  "prisma": "^5.19.1",
41
+ "tsx": "^4.7.0",
40
42
  "typescript": "^5.3.3"
41
43
  },
42
44
  "files": [
@@ -6,7 +6,43 @@ async function main() {
6
6
  // Add your seed data here
7
7
  console.log('🌱 Seeding database...');
8
8
 
9
- // Example seed data
9
+ // Create some test data for the Test model
10
+ console.log('📝 Creating test entries...');
11
+
12
+ const testEntries = await Promise.all([
13
+ prisma.test.create({
14
+ data: {
15
+ name: 'API Connection Test',
16
+ message: 'This test verifies that the API can connect to the database successfully.',
17
+ status: 'active',
18
+ },
19
+ }),
20
+ prisma.test.create({
21
+ data: {
22
+ name: 'Data Validation Test',
23
+ message: 'This test ensures that data validation is working correctly across the stack.',
24
+ status: 'active',
25
+ },
26
+ }),
27
+ prisma.test.create({
28
+ data: {
29
+ name: 'tRPC Integration Test',
30
+ message: 'This test confirms that tRPC endpoints are properly configured and accessible.',
31
+ status: 'active',
32
+ },
33
+ }),
34
+ prisma.test.create({
35
+ data: {
36
+ name: 'Sample Inactive Test',
37
+ message: 'This is an example of an inactive test entry.',
38
+ status: 'inactive',
39
+ },
40
+ }),
41
+ ]);
42
+
43
+ console.log(`✅ Created ${testEntries.length} test entries`);
44
+
45
+ // Example seed data for other models (uncommented for reference)
10
46
  // const user = await prisma.user.create({
11
47
  // data: {
12
48
  // email: 'admin@example.com',
@@ -7,10 +7,20 @@ generator client {
7
7
  }
8
8
 
9
9
  datasource db {
10
- provider = "sqlite"
10
+ provider = "postgres"
11
11
  url = env("DATABASE_URL")
12
12
  }
13
13
 
14
+ // Simple Test model for quick API testing
15
+ model Test {
16
+ id String @id @default(cuid())
17
+ name String
18
+ message String
19
+ status String @default("active") // "active", "inactive"
20
+ createdAt DateTime @default(now())
21
+ updatedAt DateTime @updatedAt
22
+ }
23
+
14
24
  // Demo User model with profile information
15
25
  model User {
16
26
  id String @id @default(cuid())
@@ -1,6 +1,6 @@
1
1
  import '@idealyst/theme/unistyles';
2
2
 
3
3
  import { AppRegistry } from 'react-native';
4
- import App from './App';
4
+ import App from './src/App';
5
5
 
6
6
  AppRegistry.registerComponent('{{projectName}}', () => App);
@@ -16,7 +16,7 @@ const config = {
16
16
  path.resolve(__dirname, '..', 'node_modules'),
17
17
  ],
18
18
  // Important for Idealyst to use .native extensions for React Native (eg: @idealyst/components/src/Button/Button.native.tsx)
19
- sourceExts: ['native.tsx', 'native.ts', 'tsx', 'ts', 'native.jsx', 'native.js', 'jsx', 'js', 'json'],
19
+ sourceExts: ['native.tsx', 'native.ts', 'tsx', 'ts', 'native.jsx', 'native.js', 'jsx', 'js', 'json', 'cjs'],
20
20
  },
21
21
  watcher: {
22
22
  // When configuring custom components with .native extensions, make sure the watcher looks for them
@@ -16,6 +16,10 @@
16
16
  "@idealyst/components": "^1.0.21",
17
17
  "@idealyst/navigation": "^1.0.21",
18
18
  "@idealyst/theme": "^1.0.21",
19
+ "@tanstack/react-query": "^5.83.0",
20
+ "@trpc/client": "^11.5.1",
21
+ "@trpc/react-query": "^11.5.1",
22
+ "@trpc/server": "^11.5.1",
19
23
  "react": "^18.2.0",
20
24
  "react-native": "^0.73.0"
21
25
  },
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { App } from '@{{workspaceScope}}/shared';
3
+
4
+ // Main App component using shared App wrapper
5
+ function AppWithShared() {
6
+ return (
7
+ <App
8
+ apiUrl="http://localhost:3000/trpc"
9
+ name="{{projectName}} Developer"
10
+ platform="mobile"
11
+ projectName="{{projectName}}"
12
+ />
13
+ );
14
+ }
15
+
16
+ export default AppWithShared;