@idealyst/cli 1.0.36 → 1.0.38
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/dist/generators/api.js +3 -4
- package/dist/generators/api.js.map +1 -1
- package/dist/generators/database.js +32 -0
- package/dist/generators/database.js.map +1 -0
- package/dist/generators/index.js +5 -0
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/utils.js +2 -1
- package/dist/generators/utils.js.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/templates/api/.env.example +6 -0
- package/dist/templates/api/README.md +25 -35
- package/dist/templates/api/package.json +0 -8
- package/dist/templates/api/src/context.ts +4 -8
- package/dist/templates/database/.env.example +8 -0
- package/dist/templates/database/README.md +93 -0
- package/dist/templates/database/__tests__/database.test.ts +14 -0
- package/dist/templates/database/jest.config.js +19 -0
- package/dist/templates/database/jest.setup.js +11 -0
- package/dist/templates/database/package.json +61 -0
- package/dist/templates/{api → database}/prisma/schema.prisma +1 -1
- package/dist/templates/database/prisma/seed.ts +28 -0
- package/dist/templates/database/src/client.ts +18 -0
- package/dist/templates/database/src/index.ts +11 -0
- package/dist/templates/database/src/schemas.ts +26 -0
- package/dist/templates/database/tsconfig.json +32 -0
- package/dist/templates/workspace/.devcontainer/Dockerfile +23 -0
- package/dist/templates/workspace/.devcontainer/README.md +0 -0
- package/dist/templates/workspace/.devcontainer/devcontainer.json +71 -99
- package/dist/templates/workspace/.devcontainer/docker-compose.yml +19 -46
- package/dist/templates/workspace/.devcontainer/fix-permissions.sh +0 -0
- package/dist/templates/workspace/.devcontainer/post-create.sh +0 -89
- package/dist/templates/workspace/.devcontainer/setup.sh +64 -0
- package/dist/templates/workspace/Dockerfile +24 -6
- package/dist/types/generators/database.d.ts +2 -0
- package/dist/types/generators/index.d.ts +1 -0
- package/dist/types/types.d.ts +1 -1
- package/package.json +8 -3
- package/templates/api/.env.example +6 -0
- package/templates/api/README.md +25 -35
- package/templates/api/package.json +0 -8
- package/templates/api/src/context.ts +4 -8
- package/templates/database/.env.example +8 -0
- package/templates/database/README.md +93 -0
- package/templates/database/__tests__/database.test.ts +14 -0
- package/templates/database/jest.config.js +19 -0
- package/templates/database/jest.setup.js +11 -0
- package/templates/database/package.json +61 -0
- package/templates/{api → database}/prisma/schema.prisma +1 -1
- package/templates/database/prisma/seed.ts +28 -0
- package/templates/database/src/client.ts +18 -0
- package/templates/database/src/index.ts +11 -0
- package/templates/database/src/schemas.ts +26 -0
- package/templates/database/tsconfig.json +32 -0
- package/templates/workspace/.devcontainer/Dockerfile +4 -6
- package/templates/workspace/.devcontainer/README.md +0 -0
- package/templates/workspace/.devcontainer/docker-compose.yml +13 -27
- package/templates/workspace/.devcontainer/fix-permissions.sh +0 -0
- package/templates/workspace/.devcontainer/post-create.sh +0 -0
- package/dist/templates/api/env.example +0 -12
- package/dist/templates/workspace/.env.production +0 -56
- package/dist/templates/workspace/scripts/docker-build.sh +0 -151
- package/templates/api/env.example +0 -12
|
@@ -66,16 +66,34 @@ CMD ["nginx", "-g", "daemon off;"]
|
|
|
66
66
|
# Development stage - for use with dev containers
|
|
67
67
|
FROM base AS dev
|
|
68
68
|
|
|
69
|
+
# Install additional tools for development
|
|
70
|
+
RUN apt-get update && apt-get install -y \
|
|
71
|
+
sudo \
|
|
72
|
+
postgresql-client \
|
|
73
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
74
|
+
|
|
75
|
+
# Create dev user with proper permissions
|
|
76
|
+
RUN groupadd --gid 1000 devuser \
|
|
77
|
+
&& useradd --uid 1000 --gid devuser --shell /bin/bash --create-home devuser \
|
|
78
|
+
&& echo 'devuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
|
79
|
+
|
|
80
|
+
# Set up workspace directory with proper ownership
|
|
81
|
+
RUN mkdir -p /app && chown -R devuser:devuser /app
|
|
82
|
+
|
|
83
|
+
# Switch to dev user for remaining setup
|
|
84
|
+
USER devuser
|
|
85
|
+
WORKDIR /app
|
|
86
|
+
|
|
69
87
|
# Copy package files
|
|
70
|
-
COPY package.json yarn.lock .yarnrc.yml ./
|
|
71
|
-
COPY .yarn .yarn
|
|
88
|
+
COPY --chown=devuser:devuser package.json yarn.lock .yarnrc.yml ./
|
|
89
|
+
COPY --chown=devuser:devuser .yarn .yarn
|
|
72
90
|
|
|
73
91
|
# Create packages directory structure and copy package.json files
|
|
74
92
|
RUN mkdir -p packages/api packages/app packages/components packages/web
|
|
75
|
-
COPY packages/api/package.json ./packages/api/
|
|
76
|
-
COPY packages/app/package.json ./packages/app/
|
|
77
|
-
COPY packages/components/package.json ./packages/components/
|
|
78
|
-
COPY packages/web/package.json ./packages/web/
|
|
93
|
+
COPY --chown=devuser:devuser packages/api/package.json ./packages/api/
|
|
94
|
+
COPY --chown=devuser:devuser packages/app/package.json ./packages/app/
|
|
95
|
+
COPY --chown=devuser:devuser packages/components/package.json ./packages/components/
|
|
96
|
+
COPY --chown=devuser:devuser packages/web/package.json ./packages/web/
|
|
79
97
|
|
|
80
98
|
# Install dependencies including dev dependencies
|
|
81
99
|
RUN yarn install
|
package/dist/types/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"description": "CLI tool for generating Idealyst Framework projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -18,8 +18,13 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "
|
|
22
|
-
"
|
|
21
|
+
"build": "node scripts/build.js",
|
|
22
|
+
"build:bash": "scripts/build.sh",
|
|
23
|
+
"build:tsc": "npm run clean && tsc && npm run copy-templates",
|
|
24
|
+
"build:validate": "npm run build && npm run validate",
|
|
25
|
+
"copy-templates": "npm run clean-templates && cp -r templates dist/",
|
|
26
|
+
"clean-templates": "rm -rf dist/templates",
|
|
27
|
+
"validate": "node scripts/validate-build.js",
|
|
23
28
|
"test": "jest",
|
|
24
29
|
"test:integration": "jest __tests__/integration.test.ts",
|
|
25
30
|
"dev": "tsc --watch",
|
package/templates/api/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
This API project is built with:
|
|
6
6
|
- **tRPC** - End-to-end typesafe APIs
|
|
7
|
-
- **Prisma** - Modern database toolkit
|
|
8
7
|
- **Zod** - TypeScript-first schema validation
|
|
9
8
|
- **Express.js** - Web framework for Node.js
|
|
10
9
|
- **TypeScript** - Type-safe JavaScript
|
|
@@ -13,7 +12,7 @@ This API project is built with:
|
|
|
13
12
|
|
|
14
13
|
1. **Setup environment variables:**
|
|
15
14
|
```bash
|
|
16
|
-
cp env.example .env
|
|
15
|
+
cp .env.example .env
|
|
17
16
|
```
|
|
18
17
|
|
|
19
18
|
2. **Install dependencies:**
|
|
@@ -21,19 +20,7 @@ This API project is built with:
|
|
|
21
20
|
yarn install
|
|
22
21
|
```
|
|
23
22
|
|
|
24
|
-
3. **
|
|
25
|
-
```bash
|
|
26
|
-
# Generate Prisma client
|
|
27
|
-
yarn db:generate
|
|
28
|
-
|
|
29
|
-
# Push schema to database (for development)
|
|
30
|
-
yarn db:push
|
|
31
|
-
|
|
32
|
-
# Or run migrations (for production)
|
|
33
|
-
yarn db:migrate
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
4. **Start development server:**
|
|
23
|
+
3. **Start development server:**
|
|
37
24
|
```bash
|
|
38
25
|
yarn dev
|
|
39
26
|
```
|
|
@@ -45,11 +32,6 @@ The API will be available at `http://localhost:3000`
|
|
|
45
32
|
- `yarn dev` - Start development server with hot reload
|
|
46
33
|
- `yarn build` - Build for production
|
|
47
34
|
- `yarn start` - Start production server
|
|
48
|
-
- `yarn db:generate` - Generate Prisma client
|
|
49
|
-
- `yarn db:push` - Push schema changes to database
|
|
50
|
-
- `yarn db:studio` - Open Prisma Studio (database GUI)
|
|
51
|
-
- `yarn db:migrate` - Run database migrations
|
|
52
|
-
- `yarn db:reset` - Reset database and run all migrations
|
|
53
35
|
- `yarn lint` - Run ESLint
|
|
54
36
|
- `yarn type-check` - Run TypeScript type checking
|
|
55
37
|
|
|
@@ -67,13 +49,21 @@ All tRPC routes are available at `/trpc/[procedure]`
|
|
|
67
49
|
- `GET /` - API information
|
|
68
50
|
- `GET /health` - Health check
|
|
69
51
|
|
|
70
|
-
## Database
|
|
52
|
+
## Connecting to a Database
|
|
71
53
|
|
|
72
|
-
|
|
54
|
+
For database functionality, create a separate database package using:
|
|
55
|
+
```bash
|
|
56
|
+
idealyst create my-database --type database
|
|
57
|
+
```
|
|
73
58
|
|
|
74
|
-
|
|
59
|
+
Then import and use it in your API:
|
|
60
|
+
```typescript
|
|
61
|
+
// In your API context or controllers
|
|
62
|
+
import { db } from '@your-org/my-database';
|
|
75
63
|
|
|
76
|
-
|
|
64
|
+
// Use the database client
|
|
65
|
+
const users = await db.user.findMany();
|
|
66
|
+
```
|
|
77
67
|
|
|
78
68
|
## Development
|
|
79
69
|
|
|
@@ -107,9 +97,11 @@ export class PostController extends BaseController {
|
|
|
107
97
|
getAll = this.createQuery(
|
|
108
98
|
z.object({ published: z.boolean().optional() }),
|
|
109
99
|
async (input, ctx) => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
// Mock data - replace with your database calls
|
|
101
|
+
return [
|
|
102
|
+
{ id: '1', title: 'Post 1', content: 'Content 1', published: true },
|
|
103
|
+
{ id: '2', title: 'Post 2', content: 'Content 2', published: false },
|
|
104
|
+
];
|
|
113
105
|
}
|
|
114
106
|
);
|
|
115
107
|
|
|
@@ -118,7 +110,8 @@ export class PostController extends BaseController {
|
|
|
118
110
|
createPostSchema,
|
|
119
111
|
[logger, rateLimit(5, 60000), requireAuth],
|
|
120
112
|
async (input, ctx) => {
|
|
121
|
-
|
|
113
|
+
// Mock creation - replace with your database calls
|
|
114
|
+
return { id: '3', ...input, published: false };
|
|
122
115
|
}
|
|
123
116
|
);
|
|
124
117
|
|
|
@@ -127,7 +120,8 @@ export class PostController extends BaseController {
|
|
|
127
120
|
z.object({ id: z.string() }),
|
|
128
121
|
[requireAuth, requireAdmin],
|
|
129
122
|
async (input, ctx) => {
|
|
130
|
-
|
|
123
|
+
// Mock deletion - replace with your database calls
|
|
124
|
+
return { success: true, deletedId: input.id };
|
|
131
125
|
}
|
|
132
126
|
);
|
|
133
127
|
}
|
|
@@ -185,9 +179,8 @@ const healthStatus = await client.health.query();
|
|
|
185
179
|
|
|
186
180
|
## Environment Variables
|
|
187
181
|
|
|
188
|
-
Copy
|
|
182
|
+
Copy `.env.example` to `.env` and configure:
|
|
189
183
|
|
|
190
|
-
- `DATABASE_URL` - Database connection string
|
|
191
184
|
- `PORT` - Server port (default: 3000)
|
|
192
185
|
- `NODE_ENV` - Environment (development/production)
|
|
193
186
|
- `CORS_ORIGIN` - CORS origin for client requests
|
|
@@ -195,13 +188,10 @@ Copy `env.example` to `.env` and configure:
|
|
|
195
188
|
## Deployment
|
|
196
189
|
|
|
197
190
|
1. Build the project: `yarn build`
|
|
198
|
-
2.
|
|
199
|
-
3. Run migrations: `yarn db:migrate`
|
|
200
|
-
4. Start the server: `yarn start`
|
|
191
|
+
2. Start the server: `yarn start`
|
|
201
192
|
|
|
202
193
|
## Learn More
|
|
203
194
|
|
|
204
195
|
- [tRPC Documentation](https://trpc.io/)
|
|
205
|
-
- [Prisma Documentation](https://www.prisma.io/docs/)
|
|
206
196
|
- [Zod Documentation](https://zod.dev/)
|
|
207
197
|
- [Express.js Documentation](https://expressjs.com/)
|
|
@@ -18,17 +18,11 @@
|
|
|
18
18
|
"test": "jest",
|
|
19
19
|
"test:watch": "jest --watch",
|
|
20
20
|
"test:coverage": "jest --coverage",
|
|
21
|
-
"db:generate": "prisma generate",
|
|
22
|
-
"db:push": "prisma db push",
|
|
23
|
-
"db:studio": "prisma studio",
|
|
24
|
-
"db:migrate": "prisma migrate dev",
|
|
25
|
-
"db:reset": "prisma migrate reset",
|
|
26
21
|
"lint": "eslint src --ext .ts,.tsx",
|
|
27
22
|
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
28
23
|
"type-check": "tsc --noEmit"
|
|
29
24
|
},
|
|
30
25
|
"dependencies": {
|
|
31
|
-
"@prisma/client": "^5.7.1",
|
|
32
26
|
"@trpc/server": "^10.44.1",
|
|
33
27
|
"cors": "^2.8.5",
|
|
34
28
|
"dotenv": "^16.3.1",
|
|
@@ -44,7 +38,6 @@
|
|
|
44
38
|
"@typescript-eslint/parser": "^6.13.1",
|
|
45
39
|
"eslint": "^8.54.0",
|
|
46
40
|
"jest": "^29.7.0",
|
|
47
|
-
"prisma": "^5.7.1",
|
|
48
41
|
"ts-jest": "^29.1.2",
|
|
49
42
|
"tsx": "^4.6.2",
|
|
50
43
|
"typescript": "^5.3.3"
|
|
@@ -52,7 +45,6 @@
|
|
|
52
45
|
"keywords": [
|
|
53
46
|
"api",
|
|
54
47
|
"trpc",
|
|
55
|
-
"prisma",
|
|
56
48
|
"zod",
|
|
57
49
|
"typescript",
|
|
58
50
|
"express"
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { PrismaClient } from '@prisma/client';
|
|
2
1
|
import type { CreateExpressContextOptions } from '@trpc/server/adapters/express';
|
|
3
2
|
|
|
4
|
-
// Create Prisma client
|
|
5
|
-
const prisma = new PrismaClient({
|
|
6
|
-
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
|
|
7
|
-
});
|
|
8
|
-
|
|
9
3
|
export interface Context {
|
|
10
|
-
prisma: PrismaClient;
|
|
11
4
|
req: CreateExpressContextOptions['req'];
|
|
12
5
|
res: CreateExpressContextOptions['res'];
|
|
6
|
+
// Add your dependencies here (e.g., database client, external services)
|
|
7
|
+
// Example: db: PrismaClient;
|
|
13
8
|
}
|
|
14
9
|
|
|
15
10
|
export const createContext = ({ req, res }: CreateExpressContextOptions): Context => {
|
|
16
11
|
return {
|
|
17
|
-
prisma,
|
|
18
12
|
req,
|
|
19
13
|
res,
|
|
14
|
+
// Initialize your dependencies here
|
|
15
|
+
// Example: db: prisma,
|
|
20
16
|
};
|
|
21
17
|
};
|
|
22
18
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
{{description}}
|
|
4
|
+
|
|
5
|
+
A database layer built with Prisma and TypeScript, designed to be shared across multiple applications in your monorepo.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🗄️ **Prisma ORM** - Type-safe database access
|
|
10
|
+
- 📝 **Zod Schemas** - Runtime validation matching your database models
|
|
11
|
+
- 📦 **Exportable Client** - Share database access across packages
|
|
12
|
+
- 🔒 **TypeScript** - Full type safety
|
|
13
|
+
- 🧪 **Testing Setup** - Jest configuration for database testing
|
|
14
|
+
- 🔄 **Migration Scripts** - Database versioning and seeding
|
|
15
|
+
|
|
16
|
+
## Getting Started
|
|
17
|
+
|
|
18
|
+
1. **Environment Setup**
|
|
19
|
+
```bash
|
|
20
|
+
cp .env.example .env
|
|
21
|
+
# Edit .env with your database URL
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
2. **Generate Prisma Client**
|
|
25
|
+
```bash
|
|
26
|
+
yarn db:generate
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
3. **Push Schema to Database**
|
|
30
|
+
```bash
|
|
31
|
+
yarn db:push
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
4. **Open Prisma Studio** (Optional)
|
|
35
|
+
```bash
|
|
36
|
+
yarn db:studio
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
### In Other Packages
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { db, schemas } from '@your-org/{{projectName}}';
|
|
45
|
+
|
|
46
|
+
// Use the database client
|
|
47
|
+
const users = await db.user.findMany();
|
|
48
|
+
|
|
49
|
+
// Use Zod schemas for validation
|
|
50
|
+
const userData = schemas.createUser.parse(input);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Adding Models
|
|
54
|
+
|
|
55
|
+
1. Update `prisma/schema.prisma` with your models
|
|
56
|
+
2. Update `src/schemas.ts` with corresponding Zod schemas
|
|
57
|
+
3. Run `yarn db:generate` to update the client
|
|
58
|
+
4. Run `yarn db:push` to update the database
|
|
59
|
+
|
|
60
|
+
## Scripts
|
|
61
|
+
|
|
62
|
+
- `yarn build` - Build the package for distribution
|
|
63
|
+
- `yarn dev` - Run in development mode with file watching
|
|
64
|
+
- `yarn test` - Run tests
|
|
65
|
+
- `yarn test:watch` - Run tests in watch mode
|
|
66
|
+
- `yarn db:generate` - Generate Prisma client
|
|
67
|
+
- `yarn db:push` - Push schema changes to database
|
|
68
|
+
- `yarn db:studio` - Open Prisma Studio
|
|
69
|
+
- `yarn db:migrate` - Create and apply migrations
|
|
70
|
+
- `yarn db:reset` - Reset database and apply migrations
|
|
71
|
+
- `yarn db:seed` - Seed the database
|
|
72
|
+
|
|
73
|
+
## Project Structure
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
src/
|
|
77
|
+
├── index.ts # Main exports
|
|
78
|
+
├── client.ts # Prisma client setup
|
|
79
|
+
└── schemas.ts # Zod validation schemas
|
|
80
|
+
prisma/
|
|
81
|
+
├── schema.prisma # Database schema
|
|
82
|
+
└── migrations/ # Database migrations
|
|
83
|
+
__tests__/
|
|
84
|
+
└── database.test.ts # Database tests
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Best Practices
|
|
88
|
+
|
|
89
|
+
- Always update Zod schemas when changing Prisma models
|
|
90
|
+
- Use meaningful migration names
|
|
91
|
+
- Test database operations
|
|
92
|
+
- Export only what's needed from the main index
|
|
93
|
+
- Keep the client singleton pattern for performance
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { db } from '../src';
|
|
3
|
+
|
|
4
|
+
describe('Database', () => {
|
|
5
|
+
it('should export database client', () => {
|
|
6
|
+
expect(db).toBeDefined();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('should connect to database', async () => {
|
|
10
|
+
// This is a basic connection test
|
|
11
|
+
// Add your own model-specific tests here
|
|
12
|
+
expect(db.$connect).toBeDefined();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
preset: 'ts-jest',
|
|
3
|
+
testEnvironment: 'node',
|
|
4
|
+
collectCoverageFrom: [
|
|
5
|
+
'src/**/*.{ts,tsx}',
|
|
6
|
+
'!src/**/*.d.ts',
|
|
7
|
+
],
|
|
8
|
+
testMatch: [
|
|
9
|
+
'**/__tests__/**/*.test.{ts,tsx}',
|
|
10
|
+
],
|
|
11
|
+
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
|
12
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
|
|
13
|
+
transform: {
|
|
14
|
+
'^.+\\.(ts|tsx)$': 'ts-jest',
|
|
15
|
+
},
|
|
16
|
+
moduleNameMapping: {
|
|
17
|
+
'^@/(.*)$': '<rootDir>/src/$1',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Global test setup
|
|
2
|
+
import { beforeEach, afterEach } from '@jest/globals';
|
|
3
|
+
|
|
4
|
+
// Mock environment variables for testing
|
|
5
|
+
process.env.NODE_ENV = 'test';
|
|
6
|
+
process.env.DATABASE_URL = 'file:./test.db';
|
|
7
|
+
|
|
8
|
+
// Clean up after each test
|
|
9
|
+
afterEach(async () => {
|
|
10
|
+
// Add any cleanup logic here
|
|
11
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{packageName}}",
|
|
3
|
+
"version": "{{version}}",
|
|
4
|
+
"description": "{{description}}",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./client": {
|
|
14
|
+
"types": "./dist/client.d.ts",
|
|
15
|
+
"import": "./dist/client.js"
|
|
16
|
+
},
|
|
17
|
+
"./schemas": {
|
|
18
|
+
"types": "./dist/schemas.d.ts",
|
|
19
|
+
"import": "./dist/schemas.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"test": "jest",
|
|
25
|
+
"test:watch": "jest --watch",
|
|
26
|
+
"test:coverage": "jest --coverage",
|
|
27
|
+
"db:generate": "prisma generate",
|
|
28
|
+
"db:push": "prisma db push",
|
|
29
|
+
"db:studio": "prisma studio",
|
|
30
|
+
"db:migrate": "prisma migrate dev",
|
|
31
|
+
"db:reset": "prisma migrate reset",
|
|
32
|
+
"db:seed": "tsx prisma/seed.ts",
|
|
33
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
34
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
35
|
+
"type-check": "tsc --noEmit",
|
|
36
|
+
"dev": "tsx watch src/index.ts"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@prisma/client": "^5.7.1",
|
|
40
|
+
"zod": "^3.22.4"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/jest": "^29.5.12",
|
|
44
|
+
"@types/node": "^20.10.4",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
46
|
+
"@typescript-eslint/parser": "^6.13.1",
|
|
47
|
+
"dotenv": "^16.3.1",
|
|
48
|
+
"eslint": "^8.54.0",
|
|
49
|
+
"jest": "^29.7.0",
|
|
50
|
+
"prisma": "^5.7.1",
|
|
51
|
+
"ts-jest": "^29.1.2",
|
|
52
|
+
"tsx": "^4.6.2",
|
|
53
|
+
"typescript": "^5.3.3"
|
|
54
|
+
},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"database",
|
|
57
|
+
"prisma",
|
|
58
|
+
"typescript",
|
|
59
|
+
"orm"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PrismaClient } from '@prisma/client';
|
|
2
|
+
|
|
3
|
+
const prisma = new PrismaClient();
|
|
4
|
+
|
|
5
|
+
async function main() {
|
|
6
|
+
console.log('🌱 Seeding database...');
|
|
7
|
+
|
|
8
|
+
// Add your seed data here
|
|
9
|
+
// Example:
|
|
10
|
+
// const user = await prisma.user.create({
|
|
11
|
+
// data: {
|
|
12
|
+
// email: 'admin@example.com',
|
|
13
|
+
// name: 'Admin User',
|
|
14
|
+
// },
|
|
15
|
+
// });
|
|
16
|
+
// console.log('Created user:', user);
|
|
17
|
+
|
|
18
|
+
console.log('✅ Database seeded successfully!');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main()
|
|
22
|
+
.catch((e) => {
|
|
23
|
+
console.error('❌ Error seeding database:', e);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
})
|
|
26
|
+
.finally(async () => {
|
|
27
|
+
await prisma.$disconnect();
|
|
28
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PrismaClient } from '@prisma/client';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
// Prevent multiple instances of Prisma Client in development
|
|
5
|
+
var __globalPrisma: PrismaClient | undefined;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const prisma =
|
|
9
|
+
globalThis.__globalPrisma ??
|
|
10
|
+
new PrismaClient({
|
|
11
|
+
log: ['query', 'error', 'warn'],
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
15
|
+
globalThis.__globalPrisma = prisma;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default prisma;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Export Prisma client
|
|
2
|
+
export { PrismaClient } from '@prisma/client';
|
|
3
|
+
|
|
4
|
+
// Export database client instance
|
|
5
|
+
export { default as db } from './client';
|
|
6
|
+
|
|
7
|
+
// Export Zod schemas
|
|
8
|
+
export * from './schemas';
|
|
9
|
+
|
|
10
|
+
// Export types from Prisma
|
|
11
|
+
export type * from '@prisma/client';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Add your Zod schemas here to match your Prisma models
|
|
4
|
+
// Example:
|
|
5
|
+
// export const UserSchema = z.object({
|
|
6
|
+
// id: z.string().cuid(),
|
|
7
|
+
// email: z.string().email(),
|
|
8
|
+
// name: z.string().optional(),
|
|
9
|
+
// createdAt: z.date(),
|
|
10
|
+
// updatedAt: z.date(),
|
|
11
|
+
// });
|
|
12
|
+
|
|
13
|
+
// export const CreateUserSchema = UserSchema.omit({
|
|
14
|
+
// id: true,
|
|
15
|
+
// createdAt: true,
|
|
16
|
+
// updatedAt: true,
|
|
17
|
+
// });
|
|
18
|
+
|
|
19
|
+
// export const UpdateUserSchema = CreateUserSchema.partial();
|
|
20
|
+
|
|
21
|
+
// Export all your schemas
|
|
22
|
+
export const schemas = {
|
|
23
|
+
// user: UserSchema,
|
|
24
|
+
// createUser: CreateUserSchema,
|
|
25
|
+
// updateUser: UpdateUserSchema,
|
|
26
|
+
} as const;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"lib": ["ES2020"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"outDir": "./dist",
|
|
16
|
+
"rootDir": "./src",
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"allowJs": false,
|
|
19
|
+
"noUncheckedIndexedAccess": true,
|
|
20
|
+
"experimentalDecorators": true,
|
|
21
|
+
"emitDecoratorMetadata": true
|
|
22
|
+
},
|
|
23
|
+
"include": [
|
|
24
|
+
"src/**/*",
|
|
25
|
+
"prisma/**/*"
|
|
26
|
+
],
|
|
27
|
+
"exclude": [
|
|
28
|
+
"node_modules",
|
|
29
|
+
"dist",
|
|
30
|
+
"__tests__"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -9,17 +9,15 @@ RUN apt-get update && apt-get install -y \
|
|
|
9
9
|
# Enable corepack for yarn
|
|
10
10
|
RUN corepack enable
|
|
11
11
|
|
|
12
|
-
# Create workspace directory
|
|
13
|
-
RUN mkdir -p /workspace
|
|
14
|
-
|
|
15
|
-
# Set working directory
|
|
16
|
-
WORKDIR /workspace
|
|
17
|
-
|
|
18
12
|
# Install global tools that might be useful
|
|
19
13
|
RUN npm install -g @expo/cli
|
|
20
14
|
|
|
21
15
|
# Set up git (will be configured in setup script)
|
|
22
16
|
RUN git config --global init.defaultBranch main
|
|
23
17
|
|
|
18
|
+
# Create workspace directory
|
|
19
|
+
RUN mkdir -p /workspace
|
|
20
|
+
WORKDIR /workspace
|
|
21
|
+
|
|
24
22
|
# Keep container running
|
|
25
23
|
CMD ["sleep", "infinity"]
|
|
File without changes
|