@idealyst/cli 1.0.88 → 1.0.90

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 (208) hide show
  1. package/dist/generators/index.js +3 -40
  2. package/dist/generators/index.js.map +1 -1
  3. package/dist/generators/init.js +273 -0
  4. package/dist/generators/init.js.map +1 -0
  5. package/dist/generators/utils.js +5 -0
  6. package/dist/generators/utils.js.map +1 -1
  7. package/dist/index.js +20 -202
  8. package/dist/index.js.map +1 -1
  9. package/dist/scripts/configure-react-native-monorepo.js +144 -0
  10. package/dist/scripts/configure-react-native-monorepo.js.map +1 -0
  11. package/dist/{templates/workspace → template}/README.md +66 -12
  12. package/dist/template/package.json +45 -0
  13. package/{templates → dist/template/packages}/api/package.json +3 -1
  14. package/{templates → dist/template/packages}/database/package.json +1 -1
  15. package/dist/{templates/native → template/packages/mobile}/babel.config.js +1 -0
  16. package/{templates/native → dist/template/packages/mobile}/metro.config.js +4 -4
  17. package/{templates/native → dist/template/packages/mobile}/package.json +5 -2
  18. package/{templates → dist/template/packages}/shared/package.json +2 -2
  19. package/{templates → dist/template/packages}/web/package.json +4 -1
  20. package/dist/types/generators/index.d.ts +1 -7
  21. package/dist/types/generators/init.d.ts +5 -0
  22. package/dist/types/scripts/configure-react-native-monorepo.d.ts +23 -0
  23. package/dist/types/types.d.ts +0 -4
  24. package/package.json +1 -1
  25. package/dist/generators/api.js +0 -31
  26. package/dist/generators/api.js.map +0 -1
  27. package/dist/generators/database.js +0 -31
  28. package/dist/generators/database.js.map +0 -1
  29. package/dist/generators/fullstack.js +0 -418
  30. package/dist/generators/fullstack.js.map +0 -1
  31. package/dist/generators/native.js +0 -112
  32. package/dist/generators/native.js.map +0 -1
  33. package/dist/generators/shared.js +0 -29
  34. package/dist/generators/shared.js.map +0 -1
  35. package/dist/generators/web.js +0 -45
  36. package/dist/generators/web.js.map +0 -1
  37. package/dist/generators/workspace.js +0 -83
  38. package/dist/generators/workspace.js.map +0 -1
  39. package/dist/templates/api/package.json +0 -54
  40. package/dist/templates/database/package.json +0 -49
  41. package/dist/templates/native/metro.config.js +0 -27
  42. package/dist/templates/native/package.json +0 -49
  43. package/dist/templates/native/src/App.tsx +0 -8
  44. package/dist/templates/shared/package.json +0 -62
  45. package/dist/templates/shared/src/components/App.tsx +0 -47
  46. package/dist/templates/shared/src/components/HelloWorld.tsx +0 -307
  47. package/dist/templates/shared/src/navigation/AppRouter.tsx +0 -98
  48. package/dist/templates/web/package.json +0 -66
  49. package/dist/templates/web/src/App.tsx +0 -14
  50. package/dist/templates/workspace/package.json +0 -35
  51. package/dist/types/generators/api.d.ts +0 -2
  52. package/dist/types/generators/database.d.ts +0 -2
  53. package/dist/types/generators/fullstack.d.ts +0 -2
  54. package/dist/types/generators/native.d.ts +0 -2
  55. package/dist/types/generators/shared.d.ts +0 -2
  56. package/dist/types/generators/web.d.ts +0 -2
  57. package/dist/types/generators/workspace.d.ts +0 -2
  58. package/templates/api/.env.example +0 -6
  59. package/templates/api/README.md +0 -274
  60. package/templates/api/__tests__/api.test.ts +0 -26
  61. package/templates/api/jest.config.js +0 -23
  62. package/templates/api/jest.setup.js +0 -9
  63. package/templates/api/src/context.ts +0 -19
  64. package/templates/api/src/controllers/TestController.ts +0 -0
  65. package/templates/api/src/index.ts +0 -9
  66. package/templates/api/src/lib/crud.ts +0 -150
  67. package/templates/api/src/lib/database.ts +0 -23
  68. package/templates/api/src/router/index.ts +0 -163
  69. package/templates/api/src/routers/test.ts +0 -59
  70. package/templates/api/src/routers/user.example.ts +0 -83
  71. package/templates/api/src/server.ts +0 -50
  72. package/templates/api/src/trpc.ts +0 -28
  73. package/templates/api/tsconfig.json +0 -43
  74. package/templates/database/README.md +0 -162
  75. package/templates/database/prisma/seed.ts +0 -64
  76. package/templates/database/schema.prisma +0 -107
  77. package/templates/database/src/index.ts +0 -15
  78. package/templates/database/src/validators.ts +0 -10
  79. package/templates/database/tsconfig.json +0 -18
  80. package/templates/native/README.md +0 -86
  81. package/templates/native/__tests__/App.test.tsx +0 -156
  82. package/templates/native/__tests__/components.test.tsx +0 -300
  83. package/templates/native/app.json +0 -5
  84. package/templates/native/babel.config.js +0 -10
  85. package/templates/native/index.js +0 -6
  86. package/templates/native/jest.config.js +0 -21
  87. package/templates/native/jest.setup.js +0 -12
  88. package/templates/native/src/App-with-trpc.tsx +0 -30
  89. package/templates/native/src/App.tsx +0 -8
  90. package/templates/native/src/utils/trpc.ts +0 -7
  91. package/templates/native/tsconfig.json +0 -28
  92. package/templates/shared/README.md +0 -135
  93. package/templates/shared/__tests__/shared.test.ts +0 -51
  94. package/templates/shared/jest.config.js +0 -22
  95. package/templates/shared/src/components/index.ts +0 -1
  96. package/templates/shared/src/index.ts +0 -14
  97. package/templates/shared/src/trpc/client.ts +0 -44
  98. package/templates/shared/tsconfig.json +0 -22
  99. package/templates/web/README.md +0 -131
  100. package/templates/web/__tests__/App.test.tsx +0 -342
  101. package/templates/web/__tests__/components.test.tsx +0 -564
  102. package/templates/web/index.html +0 -13
  103. package/templates/web/jest.config.js +0 -27
  104. package/templates/web/jest.setup.js +0 -24
  105. package/templates/web/src/App-with-trpc.tsx +0 -32
  106. package/templates/web/src/App.tsx +0 -14
  107. package/templates/web/src/components/TestDemo.tsx +0 -164
  108. package/templates/web/src/main.tsx +0 -25
  109. package/templates/web/src/utils/trpc.ts +0 -7
  110. package/templates/web/tsconfig.json +0 -26
  111. package/templates/web/vite.config.ts +0 -98
  112. package/templates/workspace/.devcontainer/Dockerfile +0 -26
  113. package/templates/workspace/.devcontainer/devcontainer.json +0 -113
  114. package/templates/workspace/.devcontainer/docker-compose.yml +0 -59
  115. package/templates/workspace/.devcontainer/figma-mcp.sh +0 -32
  116. package/templates/workspace/.devcontainer/setup.sh +0 -45
  117. package/templates/workspace/.dockerignore +0 -151
  118. package/templates/workspace/.env.example +0 -36
  119. package/templates/workspace/.env.production +0 -56
  120. package/templates/workspace/DOCKER.md +0 -0
  121. package/templates/workspace/Dockerfile +0 -111
  122. package/templates/workspace/README.md +0 -179
  123. package/templates/workspace/docker/nginx/prod.conf +0 -238
  124. package/templates/workspace/docker/nginx.conf +0 -131
  125. package/templates/workspace/docker/postgres/init.sql +0 -41
  126. package/templates/workspace/docker/prometheus/prometheus.yml +0 -52
  127. package/templates/workspace/docker-compose.prod.yml +0 -146
  128. package/templates/workspace/docker-compose.yml +0 -143
  129. package/templates/workspace/jest.config.js +0 -20
  130. package/templates/workspace/package.json +0 -38
  131. package/templates/workspace/setup.sh +0 -30
  132. package/templates/workspace/tsconfig.json +0 -31
  133. /package/dist/{templates/workspace → template}/.devcontainer/Dockerfile +0 -0
  134. /package/dist/{templates/workspace → template}/.devcontainer/devcontainer.json +0 -0
  135. /package/dist/{templates/workspace → template}/.devcontainer/docker-compose.yml +0 -0
  136. /package/dist/{templates/workspace → template}/.devcontainer/figma-mcp.sh +0 -0
  137. /package/dist/{templates/workspace → template}/.devcontainer/setup.sh +0 -0
  138. /package/dist/{templates/workspace → template}/.dockerignore +0 -0
  139. /package/dist/{templates/workspace → template}/.env.example +0 -0
  140. /package/dist/{templates/workspace → template}/DOCKER.md +0 -0
  141. /package/dist/{templates/workspace → template}/Dockerfile +0 -0
  142. /package/dist/{templates/workspace → template}/docker/nginx/prod.conf +0 -0
  143. /package/dist/{templates/workspace → template}/docker/nginx.conf +0 -0
  144. /package/dist/{templates/workspace → template}/docker/postgres/init.sql +0 -0
  145. /package/dist/{templates/workspace → template}/docker/prometheus/prometheus.yml +0 -0
  146. /package/dist/{templates/workspace → template}/docker-compose.prod.yml +0 -0
  147. /package/dist/{templates/workspace → template}/docker-compose.yml +0 -0
  148. /package/dist/{templates/workspace → template}/jest.config.js +0 -0
  149. /package/dist/{templates → template/packages}/api/.env.example +0 -0
  150. /package/dist/{templates → template/packages}/api/README.md +0 -0
  151. /package/dist/{templates → template/packages}/api/__tests__/api.test.ts +0 -0
  152. /package/dist/{templates → template/packages}/api/jest.config.js +0 -0
  153. /package/dist/{templates → template/packages}/api/jest.setup.js +0 -0
  154. /package/dist/{templates → template/packages}/api/src/context.ts +0 -0
  155. /package/dist/{templates → template/packages}/api/src/controllers/TestController.ts +0 -0
  156. /package/dist/{templates → template/packages}/api/src/index.ts +0 -0
  157. /package/dist/{templates → template/packages}/api/src/lib/crud.ts +0 -0
  158. /package/dist/{templates → template/packages}/api/src/lib/database.ts +0 -0
  159. /package/dist/{templates → template/packages}/api/src/router/index.ts +0 -0
  160. /package/dist/{templates → template/packages}/api/src/routers/test.ts +0 -0
  161. /package/dist/{templates → template/packages}/api/src/routers/user.example.ts +0 -0
  162. /package/dist/{templates → template/packages}/api/src/server.ts +0 -0
  163. /package/dist/{templates → template/packages}/api/src/trpc.ts +0 -0
  164. /package/dist/{templates → template/packages}/api/tsconfig.json +0 -0
  165. /package/dist/{templates → template/packages}/database/README.md +0 -0
  166. /package/dist/{templates → template/packages}/database/prisma/seed.ts +0 -0
  167. /package/dist/{templates → template/packages}/database/schema.prisma +0 -0
  168. /package/dist/{templates → template/packages}/database/src/index.ts +0 -0
  169. /package/dist/{templates → template/packages}/database/src/validators.ts +0 -0
  170. /package/dist/{templates → template/packages}/database/tsconfig.json +0 -0
  171. /package/dist/{templates/native → template/packages/mobile}/README.md +0 -0
  172. /package/dist/{templates/native → template/packages/mobile}/__tests__/App.test.tsx +0 -0
  173. /package/dist/{templates/native → template/packages/mobile}/__tests__/components.test.tsx +0 -0
  174. /package/dist/{templates/native → template/packages/mobile}/app.json +0 -0
  175. /package/dist/{templates/native → template/packages/mobile}/index.js +0 -0
  176. /package/dist/{templates/native → template/packages/mobile}/jest.config.js +0 -0
  177. /package/dist/{templates/native → template/packages/mobile}/jest.setup.js +0 -0
  178. /package/dist/{templates/native → template/packages/mobile}/src/App-with-trpc-and-shared.tsx +0 -0
  179. /package/dist/{templates/native → template/packages/mobile}/src/App-with-trpc.tsx +0 -0
  180. /package/{templates/native/src/App-with-trpc-and-shared.tsx → dist/template/packages/mobile/src/App.tsx} +0 -0
  181. /package/dist/{templates/native → template/packages/mobile}/src/utils/trpc.ts +0 -0
  182. /package/dist/{templates/native → template/packages/mobile}/tsconfig.json +0 -0
  183. /package/dist/{templates → template/packages}/shared/README.md +0 -0
  184. /package/dist/{templates → template/packages}/shared/__tests__/shared.test.ts +0 -0
  185. /package/dist/{templates → template/packages}/shared/jest.config.js +0 -0
  186. /package/{templates → dist/template/packages}/shared/src/components/App.tsx +0 -0
  187. /package/{templates → dist/template/packages}/shared/src/components/HelloWorld.tsx +0 -0
  188. /package/dist/{templates → template/packages}/shared/src/components/index.ts +0 -0
  189. /package/dist/{templates → template/packages}/shared/src/index.ts +0 -0
  190. /package/{templates → dist/template/packages}/shared/src/navigation/AppRouter.tsx +0 -0
  191. /package/dist/{templates → template/packages}/shared/src/trpc/client.ts +0 -0
  192. /package/dist/{templates → template/packages}/shared/tsconfig.json +0 -0
  193. /package/dist/{templates → template/packages}/web/README.md +0 -0
  194. /package/dist/{templates → template/packages}/web/__tests__/App.test.tsx +0 -0
  195. /package/dist/{templates → template/packages}/web/__tests__/components.test.tsx +0 -0
  196. /package/dist/{templates → template/packages}/web/index.html +0 -0
  197. /package/dist/{templates → template/packages}/web/jest.config.js +0 -0
  198. /package/dist/{templates → template/packages}/web/jest.setup.js +0 -0
  199. /package/dist/{templates → template/packages}/web/src/App-with-trpc-and-shared.tsx +0 -0
  200. /package/dist/{templates → template/packages}/web/src/App-with-trpc.tsx +0 -0
  201. /package/{templates/web/src/App-with-trpc-and-shared.tsx → dist/template/packages/web/src/App.tsx} +0 -0
  202. /package/dist/{templates → template/packages}/web/src/components/TestDemo.tsx +0 -0
  203. /package/dist/{templates → template/packages}/web/src/main.tsx +0 -0
  204. /package/dist/{templates → template/packages}/web/src/utils/trpc.ts +0 -0
  205. /package/dist/{templates → template/packages}/web/tsconfig.json +0 -0
  206. /package/dist/{templates → template/packages}/web/vite.config.ts +0 -0
  207. /package/dist/{templates/workspace → template}/setup.sh +0 -0
  208. /package/dist/{templates/workspace → template}/tsconfig.json +0 -0
@@ -1,59 +0,0 @@
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
- */
@@ -1,83 +0,0 @@
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
- */
@@ -1,50 +0,0 @@
1
- import express from 'express';
2
- import cors from 'cors';
3
- import { createExpressMiddleware } from '@trpc/server/adapters/express';
4
- import { appRouter } from './router/index.js';
5
- import { createContext } from './context.js';
6
- import dotenv from 'dotenv';
7
-
8
- // Load environment variables
9
- dotenv.config();
10
-
11
- const app = express();
12
- const PORT = process.env.PORT || 3000;
13
-
14
- // CORS configuration
15
- app.use(cors({
16
- origin: process.env.CORS_ORIGIN || 'http://localhost:5173',
17
- credentials: true,
18
- }));
19
-
20
- // Health check endpoint
21
- app.get('/health', (req, res) => {
22
- res.json({ status: 'OK', timestamp: new Date().toISOString() });
23
- });
24
-
25
- // tRPC middleware
26
- app.use(
27
- '/trpc',
28
- createExpressMiddleware({
29
- router: appRouter,
30
- createContext,
31
- })
32
- );
33
-
34
- // Default route
35
- app.get('/', (req, res) => {
36
- res.json({
37
- message: 'Welcome to {{projectName}} API',
38
- endpoints: {
39
- health: '/health',
40
- trpc: '/trpc',
41
- playground: '/trpc-playground' // Available in development
42
- }
43
- });
44
- });
45
-
46
- app.listen(PORT, () => {
47
- console.log(`🚀 Server running on http://localhost:${PORT}`);
48
- console.log(`📡 tRPC API available at http://localhost:${PORT}/trpc`);
49
- console.log(`🏥 Health check at http://localhost:${PORT}/health`);
50
- });
@@ -1,28 +0,0 @@
1
- import { initTRPC } from '@trpc/server';
2
- import { type Context } from './context.js';
3
- import { ZodError } from 'zod';
4
-
5
- const t = initTRPC.context<Context>().create({
6
- errorFormatter({ shape, error }) {
7
- return {
8
- ...shape,
9
- data: {
10
- ...shape.data,
11
- zodError:
12
- error.cause instanceof ZodError ? error.cause.flatten() : null,
13
- },
14
- };
15
- },
16
- });
17
-
18
- // Export reusable router and procedure helpers
19
- export const router = t.router;
20
- export const publicProcedure = t.procedure;
21
-
22
- // You can create additional procedures with middleware here
23
- // For example, a protected procedure that requires authentication:
24
- // export const protectedProcedure = t.procedure.use(async ({ ctx, next }) => {
25
- // // Add your authentication logic here
26
- // // Example: check for valid session/token
27
- // return next({ ctx: { ...ctx, user: { id: 'user-id' } } });
28
- // });
@@ -1,43 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "allowSyntheticDefaultImports": true,
6
- "esModuleInterop": true,
7
- "allowJs": true,
8
- "checkJs": false,
9
- "jsx": "preserve",
10
- "declaration": true,
11
- "declarationMap": true,
12
- "sourceMap": true,
13
- "outDir": "./dist",
14
- "rootDir": "./src",
15
- "removeComments": false,
16
- "strict": true,
17
- "noImplicitAny": true,
18
- "strictNullChecks": true,
19
- "strictFunctionTypes": true,
20
- "noImplicitThis": true,
21
- "useUnknownInCatchVariables": true,
22
- "noImplicitReturns": true,
23
- "noFallthroughCasesInSwitch": true,
24
- "noUncheckedIndexedAccess": true,
25
- "exactOptionalPropertyTypes": true,
26
- "noPropertyAccessFromIndexSignature": false,
27
- "resolveJsonModule": true,
28
- "isolatedModules": true,
29
- "forceConsistentCasingInFileNames": true,
30
- "skipLibCheck": true
31
- },
32
- "include": [
33
- "src/**/*"
34
- ],
35
- "exclude": [
36
- "node_modules",
37
- "dist",
38
- "**/*.test.ts"
39
- ],
40
- "ts-node": {
41
- "esm": true
42
- }
43
- }
@@ -1,162 +0,0 @@
1
- # Database Package
2
-
3
- This package provides database access and validation schemas for the workspace using Prisma ORM.
4
-
5
- ## Setup
6
-
7
- 1. Install dependencies:
8
- ```bash
9
- yarn install
10
- ```
11
-
12
- 2. Set up your environment:
13
- ```bash
14
- cp .env.example .env
15
- # Edit .env with your database URL
16
- ```
17
-
18
- 3. Generate the Prisma client:
19
- ```bash
20
- yarn db:generate
21
- ```
22
-
23
- 4. Push the schema to your database:
24
- ```bash
25
- yarn db:push
26
- ```
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
-
142
- ## Usage
143
-
144
- ```typescript
145
- import { prisma, User, TestValidator } from '@{{workspaceScope}}/{{name}}';
146
-
147
- // Use the database client
148
- const users = await prisma.user.findMany();
149
-
150
- // Use validators
151
- const validatedData = TestValidator.parse(userData);
152
- ```
153
-
154
- ## Scripts
155
-
156
- - `yarn db:generate` - Generate Prisma client
157
- - `yarn db:push` - Push schema to database
158
- - `yarn db:migrate` - Create and run migrations
159
- - `yarn db:studio` - Open Prisma Studio
160
- - `yarn db:reset` - Reset the database
161
- - `yarn build` - Build the package
162
- - `yarn dev` - Build in watch mode
@@ -1,64 +0,0 @@
1
- import { PrismaClient } from '../generated/client';
2
-
3
- const prisma = new PrismaClient();
4
-
5
- async function main() {
6
- // Add your seed data here
7
- console.log('🌱 Seeding database...');
8
-
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)
46
- // const user = await prisma.user.create({
47
- // data: {
48
- // email: 'admin@example.com',
49
- // name: 'Admin User',
50
- // },
51
- // });
52
-
53
- console.log('✅ Seeding completed');
54
- }
55
-
56
- main()
57
- .then(async () => {
58
- await prisma.$disconnect();
59
- })
60
- .catch(async (e) => {
61
- console.error(e);
62
- await prisma.$disconnect();
63
- process.exit(1);
64
- });
@@ -1,107 +0,0 @@
1
- // This is your Prisma schema file,
2
- // learn more about it in the docs: https://pris.ly/d/prisma-schema
3
-
4
- generator client {
5
- provider = "prisma-client-js"
6
- output = "./generated/client"
7
- }
8
-
9
- datasource db {
10
- provider = "postgres"
11
- url = env("DATABASE_URL")
12
- }
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
-
24
- // Demo User model with profile information
25
- model User {
26
- id String @id @default(cuid())
27
- email String @unique
28
- name String?
29
- avatar String? // URL to profile image
30
- bio String? // User biography
31
- location String? // User location
32
- website String? // Personal website
33
-
34
- // Posts created by this user
35
- posts Post[]
36
-
37
- // Comments made by this user
38
- comments Comment[]
39
-
40
- // User preferences and settings
41
- settings UserSettings?
42
-
43
- createdAt DateTime @default(now())
44
- updatedAt DateTime @updatedAt
45
- }
46
-
47
- // Demo Post model for a simple blog/social feed
48
- model Post {
49
- id String @id @default(cuid())
50
- title String
51
- content String
52
- excerpt String? // Short description
53
- published Boolean @default(false)
54
- tags String? // Comma-separated tag strings
55
-
56
- // Author relationship
57
- author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
58
- authorId String
59
-
60
- // Comments on this post
61
- comments Comment[]
62
-
63
- // Post metadata
64
- views Int @default(0)
65
- likes Int @default(0)
66
-
67
- createdAt DateTime @default(now())
68
- updatedAt DateTime @updatedAt
69
- }
70
-
71
- // Demo Comment model
72
- model Comment {
73
- id String @id @default(cuid())
74
- content String
75
-
76
- // Author relationship
77
- author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
78
- authorId String
79
-
80
- // Post relationship
81
- post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
82
- postId String
83
-
84
- // Parent comment for nested threading
85
- parent Comment? @relation("CommentThread", fields: [parentId], references: [id])
86
- parentId String?
87
- children Comment[] @relation("CommentThread")
88
-
89
- createdAt DateTime @default(now())
90
- updatedAt DateTime @updatedAt
91
- }
92
-
93
- // User settings and preferences
94
- model UserSettings {
95
- id String @id @default(cuid())
96
- theme String @default("auto") // "light", "dark", "auto"
97
- notifications Boolean @default(true)
98
- emailUpdates Boolean @default(false)
99
- publicProfile Boolean @default(true)
100
-
101
- // User relationship (one-to-one)
102
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
103
- userId String @unique
104
-
105
- createdAt DateTime @default(now())
106
- updatedAt DateTime @updatedAt
107
- }
@@ -1,15 +0,0 @@
1
- import { PrismaClient } from '../generated/client';
2
-
3
- declare global {
4
- var __prisma: PrismaClient | undefined;
5
- }
6
-
7
- export const prisma = globalThis.__prisma || new PrismaClient();
8
-
9
- if (process.env.NODE_ENV !== 'production') {
10
- globalThis.__prisma = prisma;
11
- }
12
-
13
- export * from './validators';
14
- export * from '../generated/client';
15
- export default prisma;
@@ -1,10 +0,0 @@
1
- // Create model validators for each model defined in the Prisma schema using Zod
2
- // E.g
3
- import { z } from 'zod';
4
-
5
- export const TestValidator = z.object({
6
- id: z.string().uuid(),
7
- email: z.string().email(),
8
- name: z.string().min(2).max(100),
9
- age: z.number().min(0).optional()
10
- });
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": ["ES2020"],
6
- "outDir": "./dist",
7
- "rootDir": "./src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "declaration": true,
13
- "declarationMap": true,
14
- "sourceMap": true
15
- },
16
- "include": ["src/**/*"],
17
- "exclude": ["node_modules", "dist"]
18
- }