@smicolon/ai-kit 0.3.2 → 0.4.0
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/README.md +73 -40
- package/dist/index.js +260 -126
- package/package.json +5 -5
- package/.claude-plugin/marketplace.json +0 -369
- package/packs/architect/CHANGELOG.md +0 -17
- package/packs/architect/README.md +0 -58
- package/packs/architect/agents/system-architect.md +0 -768
- package/packs/architect/commands/diagram-create.md +0 -300
- package/packs/better-auth/.mcp.json +0 -14
- package/packs/better-auth/CHANGELOG.md +0 -26
- package/packs/better-auth/README.md +0 -125
- package/packs/better-auth/agents/auth-architect.md +0 -278
- package/packs/better-auth/commands/auth-provider-add.md +0 -265
- package/packs/better-auth/commands/auth-setup.md +0 -298
- package/packs/better-auth/skills/auth-security/SKILL.md +0 -425
- package/packs/better-auth/skills/better-auth-patterns/SKILL.md +0 -455
- package/packs/dev-loop/CHANGELOG.md +0 -69
- package/packs/dev-loop/README.md +0 -155
- package/packs/dev-loop/commands/cancel-dev.md +0 -21
- package/packs/dev-loop/commands/dev-loop.md +0 -72
- package/packs/dev-loop/commands/dev-plan.md +0 -351
- package/packs/dev-loop/hooks/hooks.json +0 -15
- package/packs/dev-loop/hooks/stop-hook.sh +0 -178
- package/packs/dev-loop/scripts/setup-dev-loop.sh +0 -194
- package/packs/dev-loop/skills/tdd-planner/SKILL.md +0 -249
- package/packs/dev-loop/skills/tdd-planner/references/framework-patterns.md +0 -874
- package/packs/dev-loop/skills/tdd-planner/references/good-example.md +0 -260
- package/packs/dev-loop/skills/tdd-planner/references/plan-template.md +0 -275
- package/packs/django/CHANGELOG.md +0 -39
- package/packs/django/README.md +0 -92
- package/packs/django/agents/django-architect.md +0 -182
- package/packs/django/agents/django-builder.md +0 -250
- package/packs/django/agents/django-feature-based.md +0 -420
- package/packs/django/agents/django-reviewer.md +0 -253
- package/packs/django/agents/django-tester.md +0 -230
- package/packs/django/commands/api-endpoint.md +0 -285
- package/packs/django/commands/model-create.md +0 -178
- package/packs/django/commands/test-generate.md +0 -325
- package/packs/django/rules/migrations.md +0 -138
- package/packs/django/rules/models.md +0 -167
- package/packs/django/rules/serializers.md +0 -126
- package/packs/django/rules/services.md +0 -131
- package/packs/django/rules/tests.md +0 -140
- package/packs/django/rules/views.md +0 -102
- package/packs/django/skills/import-convention-enforcer/SKILL.md +0 -226
- package/packs/django/skills/import-convention-enforcer/patterns/django-imports.md +0 -343
- package/packs/django/skills/migration-safety-checker/SKILL.md +0 -375
- package/packs/django/skills/model-entity-validator/SKILL.md +0 -298
- package/packs/django/skills/performance-optimizer/SKILL.md +0 -447
- package/packs/django/skills/red-phase-verifier/SKILL.md +0 -180
- package/packs/django/skills/security-first-validator/SKILL.md +0 -435
- package/packs/django/skills/test-coverage-advisor/SKILL.md +0 -394
- package/packs/django/skills/test-validity-checker/SKILL.md +0 -194
- package/packs/failure-log/CHANGELOG.md +0 -20
- package/packs/failure-log/README.md +0 -168
- package/packs/failure-log/commands/failure-add.md +0 -106
- package/packs/failure-log/commands/failure-list.md +0 -89
- package/packs/failure-log/hooks/hooks.json +0 -16
- package/packs/failure-log/hooks/scripts/inject-failures.sh +0 -64
- package/packs/failure-log/skills/failure-log-manager/SKILL.md +0 -164
- package/packs/flutter/CHANGELOG.md +0 -19
- package/packs/flutter/README.md +0 -170
- package/packs/flutter/agents/flutter-architect.md +0 -166
- package/packs/flutter/agents/flutter-builder.md +0 -303
- package/packs/flutter/agents/release-manager.md +0 -355
- package/packs/flutter/commands/fastlane-setup.md +0 -188
- package/packs/flutter/commands/flutter-build.md +0 -90
- package/packs/flutter/commands/flutter-deploy.md +0 -133
- package/packs/flutter/commands/flutter-test.md +0 -117
- package/packs/flutter/commands/signing-setup.md +0 -209
- package/packs/flutter/hooks/hooks.json +0 -17
- package/packs/flutter/skills/fastlane-knowledge/SKILL.md +0 -193
- package/packs/flutter/skills/flutter-architecture/SKILL.md +0 -127
- package/packs/flutter/skills/store-publishing/SKILL.md +0 -163
- package/packs/hono/CHANGELOG.md +0 -19
- package/packs/hono/README.md +0 -143
- package/packs/hono/agents/hono-architect.md +0 -240
- package/packs/hono/agents/hono-builder.md +0 -285
- package/packs/hono/agents/hono-reviewer.md +0 -279
- package/packs/hono/agents/hono-tester.md +0 -346
- package/packs/hono/commands/middleware-create.md +0 -223
- package/packs/hono/commands/project-init.md +0 -306
- package/packs/hono/commands/route-create.md +0 -153
- package/packs/hono/commands/rpc-client.md +0 -263
- package/packs/hono/skills/cloudflare-bindings/SKILL.md +0 -408
- package/packs/hono/skills/hono-patterns/SKILL.md +0 -309
- package/packs/hono/skills/rpc-typesafe/SKILL.md +0 -388
- package/packs/hono/skills/zod-validation/SKILL.md +0 -332
- package/packs/nestjs/CHANGELOG.md +0 -29
- package/packs/nestjs/README.md +0 -75
- package/packs/nestjs/agents/nestjs-architect.md +0 -402
- package/packs/nestjs/agents/nestjs-builder.md +0 -301
- package/packs/nestjs/agents/nestjs-tester.md +0 -437
- package/packs/nestjs/commands/module-create.md +0 -369
- package/packs/nestjs/rules/controllers.md +0 -92
- package/packs/nestjs/rules/dto.md +0 -124
- package/packs/nestjs/rules/entities.md +0 -102
- package/packs/nestjs/rules/services.md +0 -106
- package/packs/nestjs/skills/barrel-export-manager/SKILL.md +0 -389
- package/packs/nestjs/skills/import-convention-enforcer/SKILL.md +0 -365
- package/packs/nextjs/CHANGELOG.md +0 -36
- package/packs/nextjs/README.md +0 -76
- package/packs/nextjs/agents/frontend-tester.md +0 -680
- package/packs/nextjs/agents/frontend-visual.md +0 -820
- package/packs/nextjs/agents/nextjs-architect.md +0 -331
- package/packs/nextjs/agents/nextjs-modular.md +0 -433
- package/packs/nextjs/commands/component-create.md +0 -398
- package/packs/nextjs/rules/api-routes.md +0 -129
- package/packs/nextjs/rules/components.md +0 -106
- package/packs/nextjs/rules/hooks.md +0 -132
- package/packs/nextjs/skills/accessibility-validator/SKILL.md +0 -445
- package/packs/nextjs/skills/import-convention-enforcer/SKILL.md +0 -399
- package/packs/nextjs/skills/react-form-validator/SKILL.md +0 -569
- package/packs/nuxtjs/CHANGELOG.md +0 -30
- package/packs/nuxtjs/README.md +0 -56
- package/packs/nuxtjs/agents/frontend-tester.md +0 -680
- package/packs/nuxtjs/agents/frontend-visual.md +0 -820
- package/packs/nuxtjs/agents/nuxtjs-architect.md +0 -537
- package/packs/nuxtjs/commands/component-create.md +0 -223
- package/packs/nuxtjs/rules/components.md +0 -101
- package/packs/nuxtjs/rules/composables.md +0 -118
- package/packs/nuxtjs/rules/server-routes.md +0 -127
- package/packs/nuxtjs/skills/accessibility-validator/SKILL.md +0 -183
- package/packs/nuxtjs/skills/import-convention-enforcer/SKILL.md +0 -196
- package/packs/nuxtjs/skills/veevalidate-form-validator/SKILL.md +0 -190
- package/packs/onboard/CHANGELOG.md +0 -22
- package/packs/onboard/README.md +0 -103
- package/packs/onboard/agents/onboard-guide.md +0 -118
- package/packs/onboard/commands/onboard.md +0 -313
- package/packs/onboard/skills/onboard-context-provider/SKILL.md +0 -98
- package/packs/tanstack-router/CHANGELOG.md +0 -30
- package/packs/tanstack-router/README.md +0 -113
- package/packs/tanstack-router/agents/tanstack-architect.md +0 -173
- package/packs/tanstack-router/agents/tanstack-builder.md +0 -360
- package/packs/tanstack-router/agents/tanstack-tester.md +0 -454
- package/packs/tanstack-router/commands/form-create.md +0 -313
- package/packs/tanstack-router/commands/query-create.md +0 -263
- package/packs/tanstack-router/commands/route-create.md +0 -190
- package/packs/tanstack-router/commands/table-create.md +0 -413
- package/packs/tanstack-router/skills/ai-patterns/SKILL.md +0 -370
- package/packs/tanstack-router/skills/db-patterns/SKILL.md +0 -346
- package/packs/tanstack-router/skills/devtools-patterns/SKILL.md +0 -415
- package/packs/tanstack-router/skills/form-patterns/SKILL.md +0 -425
- package/packs/tanstack-router/skills/pacer-patterns/SKILL.md +0 -341
- package/packs/tanstack-router/skills/query-patterns/SKILL.md +0 -359
- package/packs/tanstack-router/skills/router-patterns/SKILL.md +0 -285
- package/packs/tanstack-router/skills/store-patterns/SKILL.md +0 -351
- package/packs/tanstack-router/skills/table-patterns/SKILL.md +0 -531
- package/packs/tanstack-router/skills/tanstack-conventions/SKILL.md +0 -428
- package/packs/tanstack-router/skills/virtual-patterns/SKILL.md +0 -490
- package/packs/worktree/CHANGELOG.md +0 -45
- package/packs/worktree/README.md +0 -219
- package/packs/worktree/commands/wt.md +0 -93
- package/packs/worktree/scripts/wt.sh +0 -957
- package/packs/worktree/skills/worktree-manager/SKILL.md +0 -113
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: module-create
|
|
3
|
-
description: Create a new NestJS module following Smicolon conventions
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# NestJS Module Creation
|
|
7
|
-
|
|
8
|
-
You are a NestJS module creation specialist. Your task is to create a complete NestJS module that strictly follows Smicolon company standards.
|
|
9
|
-
|
|
10
|
-
## Core Requirements
|
|
11
|
-
|
|
12
|
-
### Import Pattern (CRITICAL)
|
|
13
|
-
ALWAYS use absolute imports from barrel exports:
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
// ✅ CORRECT - Absolute imports from barrel exports
|
|
17
|
-
import { User } from 'src/users/entities'
|
|
18
|
-
import { UsersService } from 'src/users/services'
|
|
19
|
-
import { CreateUserDto } from 'src/users/dto'
|
|
20
|
-
|
|
21
|
-
// ❌ WRONG - Relative imports
|
|
22
|
-
import { User } from './entities/user.entity'
|
|
23
|
-
import { User } from '../entities'
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### Standard Entity Fields (MANDATORY)
|
|
27
|
-
Every entity MUST include:
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import {
|
|
31
|
-
Entity,
|
|
32
|
-
PrimaryGeneratedColumn,
|
|
33
|
-
Column,
|
|
34
|
-
CreateDateColumn,
|
|
35
|
-
UpdateDateColumn,
|
|
36
|
-
DeleteDateColumn
|
|
37
|
-
} from 'typeorm'
|
|
38
|
-
|
|
39
|
-
@Entity('table_name')
|
|
40
|
-
export class YourEntity {
|
|
41
|
-
@PrimaryGeneratedColumn('uuid')
|
|
42
|
-
id: string
|
|
43
|
-
|
|
44
|
-
@CreateDateColumn()
|
|
45
|
-
createdAt: Date
|
|
46
|
-
|
|
47
|
-
@UpdateDateColumn()
|
|
48
|
-
updatedAt: Date
|
|
49
|
-
|
|
50
|
-
@DeleteDateColumn()
|
|
51
|
-
deletedAt?: Date
|
|
52
|
-
|
|
53
|
-
// Your custom fields here
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Module Structure
|
|
58
|
-
Every module needs these files:
|
|
59
|
-
```
|
|
60
|
-
src/module-name/
|
|
61
|
-
├── index.ts # Barrel export (REQUIRED)
|
|
62
|
-
├── module-name.module.ts
|
|
63
|
-
├── entities/
|
|
64
|
-
│ ├── index.ts # Barrel export
|
|
65
|
-
│ └── entity-name.entity.ts
|
|
66
|
-
├── dto/
|
|
67
|
-
│ ├── index.ts # Barrel export
|
|
68
|
-
│ ├── create-entity.dto.ts
|
|
69
|
-
│ └── update-entity.dto.ts
|
|
70
|
-
├── services/
|
|
71
|
-
│ ├── index.ts # Barrel export
|
|
72
|
-
│ └── module-name.service.ts
|
|
73
|
-
├── controllers/
|
|
74
|
-
│ ├── index.ts # Barrel export
|
|
75
|
-
│ └── module-name.controller.ts
|
|
76
|
-
└── guards/ (if needed)
|
|
77
|
-
├── index.ts
|
|
78
|
-
└── custom.guard.ts
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Workflow
|
|
82
|
-
|
|
83
|
-
1. **Understand Requirements**: Ask user for:
|
|
84
|
-
- Module name and purpose
|
|
85
|
-
- Entity fields needed
|
|
86
|
-
- API endpoints (CRUD operations)
|
|
87
|
-
- Access control needs
|
|
88
|
-
|
|
89
|
-
2. **Generate Files**: Create all necessary files with:
|
|
90
|
-
- Entity with standard fields
|
|
91
|
-
- DTOs with validation
|
|
92
|
-
- Service with business logic
|
|
93
|
-
- Controller with guards
|
|
94
|
-
- Module configuration
|
|
95
|
-
- Barrel exports
|
|
96
|
-
|
|
97
|
-
## Example Output
|
|
98
|
-
|
|
99
|
-
### Entity
|
|
100
|
-
```typescript
|
|
101
|
-
// src/products/entities/product.entity.ts
|
|
102
|
-
import {
|
|
103
|
-
Entity,
|
|
104
|
-
PrimaryGeneratedColumn,
|
|
105
|
-
Column,
|
|
106
|
-
CreateDateColumn,
|
|
107
|
-
UpdateDateColumn,
|
|
108
|
-
DeleteDateColumn,
|
|
109
|
-
ManyToOne,
|
|
110
|
-
JoinColumn
|
|
111
|
-
} from 'typeorm'
|
|
112
|
-
import { User } from 'src/users/entities'
|
|
113
|
-
|
|
114
|
-
@Entity('products')
|
|
115
|
-
export class Product {
|
|
116
|
-
@PrimaryGeneratedColumn('uuid')
|
|
117
|
-
id: string
|
|
118
|
-
|
|
119
|
-
@CreateDateColumn()
|
|
120
|
-
createdAt: Date
|
|
121
|
-
|
|
122
|
-
@UpdateDateColumn()
|
|
123
|
-
updatedAt: Date
|
|
124
|
-
|
|
125
|
-
@DeleteDateColumn()
|
|
126
|
-
deletedAt?: Date
|
|
127
|
-
|
|
128
|
-
@Column({ length: 255 })
|
|
129
|
-
name: string
|
|
130
|
-
|
|
131
|
-
@Column({ unique: true, length: 255 })
|
|
132
|
-
slug: string
|
|
133
|
-
|
|
134
|
-
@Column('text')
|
|
135
|
-
description: string
|
|
136
|
-
|
|
137
|
-
@Column('decimal', { precision: 10, scale: 2 })
|
|
138
|
-
price: number
|
|
139
|
-
|
|
140
|
-
@Column('int', { default: 0 })
|
|
141
|
-
stock: number
|
|
142
|
-
|
|
143
|
-
@ManyToOne(() => User)
|
|
144
|
-
@JoinColumn({ name: 'created_by_id' })
|
|
145
|
-
createdBy: User
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### DTOs
|
|
150
|
-
```typescript
|
|
151
|
-
// src/products/dto/create-product.dto.ts
|
|
152
|
-
import { IsString, IsNumber, IsNotEmpty, Min, MaxLength } from 'class-validator'
|
|
153
|
-
import { ApiProperty } from '@nestjs/swagger'
|
|
154
|
-
|
|
155
|
-
export class CreateProductDto {
|
|
156
|
-
@ApiProperty({ example: 'Laptop', description: 'Product name' })
|
|
157
|
-
@IsString()
|
|
158
|
-
@IsNotEmpty()
|
|
159
|
-
@MaxLength(255)
|
|
160
|
-
name: string
|
|
161
|
-
|
|
162
|
-
@ApiProperty({ example: 'laptop-2024', description: 'URL-friendly slug' })
|
|
163
|
-
@IsString()
|
|
164
|
-
@IsNotEmpty()
|
|
165
|
-
@MaxLength(255)
|
|
166
|
-
slug: string
|
|
167
|
-
|
|
168
|
-
@ApiProperty({ example: 'High-performance laptop', description: 'Product description' })
|
|
169
|
-
@IsString()
|
|
170
|
-
@IsNotEmpty()
|
|
171
|
-
description: string
|
|
172
|
-
|
|
173
|
-
@ApiProperty({ example: 999.99, description: 'Product price' })
|
|
174
|
-
@IsNumber()
|
|
175
|
-
@Min(0)
|
|
176
|
-
price: number
|
|
177
|
-
|
|
178
|
-
@ApiProperty({ example: 10, description: 'Stock quantity', required: false })
|
|
179
|
-
@IsNumber()
|
|
180
|
-
@Min(0)
|
|
181
|
-
stock?: number
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// src/products/dto/update-product.dto.ts
|
|
185
|
-
import { PartialType } from '@nestjs/mapped-types'
|
|
186
|
-
import { CreateProductDto } from './create-product.dto'
|
|
187
|
-
|
|
188
|
-
export class UpdateProductDto extends PartialType(CreateProductDto) {}
|
|
189
|
-
|
|
190
|
-
// src/products/dto/index.ts
|
|
191
|
-
export * from './create-product.dto'
|
|
192
|
-
export * from './update-product.dto'
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### Service
|
|
196
|
-
```typescript
|
|
197
|
-
// src/products/services/product.service.ts
|
|
198
|
-
import { Injectable, NotFoundException } from '@nestjs/common'
|
|
199
|
-
import { InjectRepository } from '@nestjs/typeorm'
|
|
200
|
-
import { Repository } from 'typeorm'
|
|
201
|
-
import { Product } from 'src/products/entities'
|
|
202
|
-
import { CreateProductDto, UpdateProductDto } from 'src/products/dto'
|
|
203
|
-
|
|
204
|
-
@Injectable()
|
|
205
|
-
export class ProductService {
|
|
206
|
-
constructor(
|
|
207
|
-
@InjectRepository(Product)
|
|
208
|
-
private readonly productRepository: Repository<Product>,
|
|
209
|
-
) {}
|
|
210
|
-
|
|
211
|
-
async create(createProductDto: CreateProductDto, userId: string): Promise<Product> {
|
|
212
|
-
const product = this.productRepository.create({
|
|
213
|
-
...createProductDto,
|
|
214
|
-
createdBy: { id: userId } as any,
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
return await this.productRepository.save(product)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
async findAll(): Promise<Product[]> {
|
|
221
|
-
return await this.productRepository.find({
|
|
222
|
-
relations: ['createdBy'],
|
|
223
|
-
order: { createdAt: 'DESC' },
|
|
224
|
-
})
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
async findOne(id: string): Promise<Product> {
|
|
228
|
-
const product = await this.productRepository.findOne({
|
|
229
|
-
where: { id },
|
|
230
|
-
relations: ['createdBy'],
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
if (!product) {
|
|
234
|
-
throw new NotFoundException(`Product with ID ${id} not found`)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return product
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
async update(id: string, updateProductDto: UpdateProductDto): Promise<Product> {
|
|
241
|
-
const product = await this.findOne(id)
|
|
242
|
-
|
|
243
|
-
Object.assign(product, updateProductDto)
|
|
244
|
-
|
|
245
|
-
return await this.productRepository.save(product)
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async remove(id: string): Promise<void> {
|
|
249
|
-
const product = await this.findOne(id)
|
|
250
|
-
await this.productRepository.softRemove(product)
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
async restock(id: string, quantity: number): Promise<Product> {
|
|
254
|
-
const product = await this.findOne(id)
|
|
255
|
-
product.stock += quantity
|
|
256
|
-
return await this.productRepository.save(product)
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// src/products/services/index.ts
|
|
261
|
-
export * from './product.service'
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### Controller
|
|
265
|
-
```typescript
|
|
266
|
-
// src/products/controllers/product.controller.ts
|
|
267
|
-
import {
|
|
268
|
-
Controller,
|
|
269
|
-
Get,
|
|
270
|
-
Post,
|
|
271
|
-
Body,
|
|
272
|
-
Patch,
|
|
273
|
-
Param,
|
|
274
|
-
Delete,
|
|
275
|
-
UseGuards,
|
|
276
|
-
Request,
|
|
277
|
-
} from '@nestjs/common'
|
|
278
|
-
import { ApiBearerAuth, ApiTags, ApiOperation } from '@nestjs/swagger'
|
|
279
|
-
import { JwtAuthGuard } from 'src/auth/guards'
|
|
280
|
-
import { ProductService } from 'src/products/services'
|
|
281
|
-
import { CreateProductDto, UpdateProductDto } from 'src/products/dto'
|
|
282
|
-
|
|
283
|
-
@ApiTags('products')
|
|
284
|
-
@ApiBearerAuth()
|
|
285
|
-
@UseGuards(JwtAuthGuard)
|
|
286
|
-
@Controller('products')
|
|
287
|
-
export class ProductController {
|
|
288
|
-
constructor(private readonly productService: ProductService) {}
|
|
289
|
-
|
|
290
|
-
@Post()
|
|
291
|
-
@ApiOperation({ summary: 'Create a new product' })
|
|
292
|
-
create(@Body() createProductDto: CreateProductDto, @Request() req) {
|
|
293
|
-
return this.productService.create(createProductDto, req.user.id)
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
@Get()
|
|
297
|
-
@ApiOperation({ summary: 'Get all products' })
|
|
298
|
-
findAll() {
|
|
299
|
-
return this.productService.findAll()
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
@Get(':id')
|
|
303
|
-
@ApiOperation({ summary: 'Get a product by ID' })
|
|
304
|
-
findOne(@Param('id') id: string) {
|
|
305
|
-
return this.productService.findOne(id)
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
@Patch(':id')
|
|
309
|
-
@ApiOperation({ summary: 'Update a product' })
|
|
310
|
-
update(@Param('id') id: string, @Body() updateProductDto: UpdateProductDto) {
|
|
311
|
-
return this.productService.update(id, updateProductDto)
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
@Delete(':id')
|
|
315
|
-
@ApiOperation({ summary: 'Delete a product' })
|
|
316
|
-
remove(@Param('id') id: string) {
|
|
317
|
-
return this.productService.remove(id)
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
@Post(':id/restock')
|
|
321
|
-
@ApiOperation({ summary: 'Restock a product' })
|
|
322
|
-
restock(@Param('id') id: string, @Body('quantity') quantity: number) {
|
|
323
|
-
return this.productService.restock(id, quantity)
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// src/products/controllers/index.ts
|
|
328
|
-
export * from './product.controller'
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
### Module
|
|
332
|
-
```typescript
|
|
333
|
-
// src/products/products.module.ts
|
|
334
|
-
import { Module } from '@nestjs/common'
|
|
335
|
-
import { TypeOrmModule } from '@nestjs/typeorm'
|
|
336
|
-
import { Product } from './entities'
|
|
337
|
-
import { ProductService } from './services'
|
|
338
|
-
import { ProductController } from './controllers'
|
|
339
|
-
|
|
340
|
-
@Module({
|
|
341
|
-
imports: [TypeOrmModule.forFeature([Product])],
|
|
342
|
-
controllers: [ProductController],
|
|
343
|
-
providers: [ProductService],
|
|
344
|
-
exports: [ProductService],
|
|
345
|
-
})
|
|
346
|
-
export class ProductsModule {}
|
|
347
|
-
|
|
348
|
-
// src/products/index.ts (Barrel export)
|
|
349
|
-
export * from './products.module'
|
|
350
|
-
export * from './entities'
|
|
351
|
-
export * from './dto'
|
|
352
|
-
export * from './services'
|
|
353
|
-
export * from './controllers'
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
## Quality Checklist
|
|
357
|
-
|
|
358
|
-
- [ ] UUID primary keys
|
|
359
|
-
- [ ] Timestamps (createdAt, updatedAt)
|
|
360
|
-
- [ ] Soft deletes (deletedAt)
|
|
361
|
-
- [ ] Absolute imports from barrel exports
|
|
362
|
-
- [ ] DTOs with class-validator
|
|
363
|
-
- [ ] Guards on protected routes
|
|
364
|
-
- [ ] Swagger/OpenAPI documentation
|
|
365
|
-
- [ ] Barrel exports (index.ts) in all folders
|
|
366
|
-
- [ ] Service methods with proper error handling
|
|
367
|
-
- [ ] Repository pattern with TypeORM
|
|
368
|
-
|
|
369
|
-
Now, ask the user what module they want to create!
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.controller.ts"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# NestJS Controller Standards
|
|
7
|
-
|
|
8
|
-
## Structure
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
import { Controller, Get, Post, Body, UseGuards } from '@nestjs/common'
|
|
12
|
-
import { JwtAuthGuard } from 'src/auth/guards'
|
|
13
|
-
import { User } from 'src/users/entities'
|
|
14
|
-
import { UsersService } from 'src/users/services'
|
|
15
|
-
import { CreateUserDto, UserResponseDto } from 'src/users/dto'
|
|
16
|
-
|
|
17
|
-
@Controller('users')
|
|
18
|
-
@UseGuards(JwtAuthGuard) // REQUIRED
|
|
19
|
-
export class UsersController {
|
|
20
|
-
constructor(private readonly usersService: UsersService) {}
|
|
21
|
-
|
|
22
|
-
@Post()
|
|
23
|
-
async create(@Body() dto: CreateUserDto): Promise<UserResponseDto> {
|
|
24
|
-
return this.usersService.create(dto)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Requirements
|
|
30
|
-
|
|
31
|
-
- Guards on all protected routes (@UseGuards)
|
|
32
|
-
- DTOs for all inputs
|
|
33
|
-
- Response DTOs for outputs
|
|
34
|
-
- Absolute imports from barrel exports
|
|
35
|
-
- Constructor injection for dependencies
|
|
36
|
-
|
|
37
|
-
## Import Pattern
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
// CORRECT - Absolute imports from barrel exports
|
|
41
|
-
import { UsersService } from 'src/users/services'
|
|
42
|
-
import { CreateUserDto } from 'src/users/dto'
|
|
43
|
-
import { User } from 'src/users/entities'
|
|
44
|
-
|
|
45
|
-
// WRONG - Relative imports
|
|
46
|
-
import { UsersService } from './users.service'
|
|
47
|
-
import { CreateUserDto } from '../dto/create-user.dto'
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Method Decorators
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
@Controller('users')
|
|
54
|
-
@UseGuards(JwtAuthGuard)
|
|
55
|
-
export class UsersController {
|
|
56
|
-
@Get()
|
|
57
|
-
findAll(): Promise<UserResponseDto[]> {
|
|
58
|
-
return this.usersService.findAll()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@Get(':id')
|
|
62
|
-
findOne(@Param('id', ParseUUIDPipe) id: string): Promise<UserResponseDto> {
|
|
63
|
-
return this.usersService.findOne(id)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@Post()
|
|
67
|
-
create(@Body() dto: CreateUserDto): Promise<UserResponseDto> {
|
|
68
|
-
return this.usersService.create(dto)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@Patch(':id')
|
|
72
|
-
update(
|
|
73
|
-
@Param('id', ParseUUIDPipe) id: string,
|
|
74
|
-
@Body() dto: UpdateUserDto,
|
|
75
|
-
): Promise<UserResponseDto> {
|
|
76
|
-
return this.usersService.update(id, dto)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@Delete(':id')
|
|
80
|
-
@HttpCode(HttpStatus.NO_CONTENT)
|
|
81
|
-
remove(@Param('id', ParseUUIDPipe) id: string): Promise<void> {
|
|
82
|
-
return this.usersService.remove(id)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Forbidden Patterns
|
|
88
|
-
|
|
89
|
-
- Controllers without @UseGuards
|
|
90
|
-
- Direct repository access (use services)
|
|
91
|
-
- Business logic in controllers
|
|
92
|
-
- Any type in parameters or return types
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.dto.ts"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# NestJS DTO Standards
|
|
7
|
-
|
|
8
|
-
## Structure
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
import { IsEmail, IsString, MinLength, IsOptional } from 'class-validator'
|
|
12
|
-
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
|
|
13
|
-
|
|
14
|
-
export class CreateUserDto {
|
|
15
|
-
@ApiProperty({ description: 'User email address' })
|
|
16
|
-
@IsEmail()
|
|
17
|
-
email: string
|
|
18
|
-
|
|
19
|
-
@ApiProperty({ description: 'User password', minLength: 8 })
|
|
20
|
-
@IsString()
|
|
21
|
-
@MinLength(8)
|
|
22
|
-
password: string
|
|
23
|
-
|
|
24
|
-
@ApiPropertyOptional({ description: 'User first name' })
|
|
25
|
-
@IsOptional()
|
|
26
|
-
@IsString()
|
|
27
|
-
firstName?: string
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Requirements
|
|
32
|
-
|
|
33
|
-
- class-validator decorators for validation
|
|
34
|
-
- @nestjs/swagger decorators for API documentation
|
|
35
|
-
- Separate DTOs for create, update, response
|
|
36
|
-
- Export from barrel (index.ts)
|
|
37
|
-
|
|
38
|
-
## Naming Convention
|
|
39
|
-
|
|
40
|
-
- Create DTOs: `Create{Entity}Dto`
|
|
41
|
-
- Update DTOs: `Update{Entity}Dto`
|
|
42
|
-
- Response DTOs: `{Entity}ResponseDto`
|
|
43
|
-
- Query DTOs: `{Entity}QueryDto`
|
|
44
|
-
|
|
45
|
-
## Update DTOs with PartialType
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
import { PartialType } from '@nestjs/swagger'
|
|
49
|
-
import { CreateUserDto } from './create-user.dto'
|
|
50
|
-
|
|
51
|
-
export class UpdateUserDto extends PartialType(CreateUserDto) {}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Response DTOs
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
import { Exclude, Expose } from 'class-transformer'
|
|
58
|
-
|
|
59
|
-
export class UserResponseDto {
|
|
60
|
-
@Expose()
|
|
61
|
-
id: string
|
|
62
|
-
|
|
63
|
-
@Expose()
|
|
64
|
-
email: string
|
|
65
|
-
|
|
66
|
-
@Expose()
|
|
67
|
-
firstName: string
|
|
68
|
-
|
|
69
|
-
@Expose()
|
|
70
|
-
createdAt: Date
|
|
71
|
-
|
|
72
|
-
@Exclude()
|
|
73
|
-
password: string // Never expose
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Validation Examples
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
import {
|
|
81
|
-
IsEmail,
|
|
82
|
-
IsString,
|
|
83
|
-
MinLength,
|
|
84
|
-
MaxLength,
|
|
85
|
-
IsUUID,
|
|
86
|
-
IsEnum,
|
|
87
|
-
IsInt,
|
|
88
|
-
Min,
|
|
89
|
-
Max,
|
|
90
|
-
IsArray,
|
|
91
|
-
ValidateNested,
|
|
92
|
-
} from 'class-validator'
|
|
93
|
-
import { Type } from 'class-transformer'
|
|
94
|
-
|
|
95
|
-
export class CreateOrderDto {
|
|
96
|
-
@IsUUID()
|
|
97
|
-
userId: string
|
|
98
|
-
|
|
99
|
-
@IsArray()
|
|
100
|
-
@ValidateNested({ each: true })
|
|
101
|
-
@Type(() => OrderItemDto)
|
|
102
|
-
items: OrderItemDto[]
|
|
103
|
-
|
|
104
|
-
@IsEnum(PaymentMethod)
|
|
105
|
-
paymentMethod: PaymentMethod
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export class OrderItemDto {
|
|
109
|
-
@IsUUID()
|
|
110
|
-
productId: string
|
|
111
|
-
|
|
112
|
-
@IsInt()
|
|
113
|
-
@Min(1)
|
|
114
|
-
@Max(100)
|
|
115
|
-
quantity: number
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Forbidden Patterns
|
|
120
|
-
|
|
121
|
-
- DTOs without validation decorators
|
|
122
|
-
- Exposing sensitive fields in response DTOs
|
|
123
|
-
- Using `any` type
|
|
124
|
-
- Missing Swagger documentation
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.entity.ts"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# NestJS Entity Standards
|
|
7
|
-
|
|
8
|
-
## Structure
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
import {
|
|
12
|
-
Entity,
|
|
13
|
-
PrimaryGeneratedColumn,
|
|
14
|
-
Column,
|
|
15
|
-
CreateDateColumn,
|
|
16
|
-
UpdateDateColumn,
|
|
17
|
-
DeleteDateColumn,
|
|
18
|
-
} from 'typeorm'
|
|
19
|
-
|
|
20
|
-
@Entity('users')
|
|
21
|
-
export class User {
|
|
22
|
-
@PrimaryGeneratedColumn('uuid')
|
|
23
|
-
id: string
|
|
24
|
-
|
|
25
|
-
@Column({ unique: true })
|
|
26
|
-
email: string
|
|
27
|
-
|
|
28
|
-
@CreateDateColumn()
|
|
29
|
-
createdAt: Date
|
|
30
|
-
|
|
31
|
-
@UpdateDateColumn()
|
|
32
|
-
updatedAt: Date
|
|
33
|
-
|
|
34
|
-
@DeleteDateColumn()
|
|
35
|
-
deletedAt?: Date // Soft delete
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Requirements
|
|
40
|
-
|
|
41
|
-
- UUID primary keys (@PrimaryGeneratedColumn('uuid'))
|
|
42
|
-
- Timestamps (createdAt, updatedAt)
|
|
43
|
-
- Soft delete (deletedAt with @DeleteDateColumn)
|
|
44
|
-
- Explicit table name in @Entity()
|
|
45
|
-
- Export from barrel (index.ts)
|
|
46
|
-
|
|
47
|
-
## Relationships
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
import { Entity, ManyToOne, OneToMany, JoinColumn } from 'typeorm'
|
|
51
|
-
import { User } from 'src/users/entities'
|
|
52
|
-
import { OrderItem } from 'src/orders/entities'
|
|
53
|
-
|
|
54
|
-
@Entity('orders')
|
|
55
|
-
export class Order {
|
|
56
|
-
@PrimaryGeneratedColumn('uuid')
|
|
57
|
-
id: string
|
|
58
|
-
|
|
59
|
-
@ManyToOne(() => User, user => user.orders)
|
|
60
|
-
@JoinColumn({ name: 'user_id' })
|
|
61
|
-
user: User
|
|
62
|
-
|
|
63
|
-
@Column({ name: 'user_id' })
|
|
64
|
-
userId: string
|
|
65
|
-
|
|
66
|
-
@OneToMany(() => OrderItem, item => item.order)
|
|
67
|
-
items: OrderItem[]
|
|
68
|
-
|
|
69
|
-
@CreateDateColumn()
|
|
70
|
-
createdAt: Date
|
|
71
|
-
|
|
72
|
-
@UpdateDateColumn()
|
|
73
|
-
updatedAt: Date
|
|
74
|
-
|
|
75
|
-
@DeleteDateColumn()
|
|
76
|
-
deletedAt?: Date
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Column Options
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
@Column({ length: 100 })
|
|
84
|
-
firstName: string
|
|
85
|
-
|
|
86
|
-
@Column({ type: 'decimal', precision: 10, scale: 2 })
|
|
87
|
-
price: number
|
|
88
|
-
|
|
89
|
-
@Column({ type: 'enum', enum: OrderStatus, default: OrderStatus.PENDING })
|
|
90
|
-
status: OrderStatus
|
|
91
|
-
|
|
92
|
-
@Column({ nullable: true })
|
|
93
|
-
description?: string
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Forbidden Patterns
|
|
97
|
-
|
|
98
|
-
- Auto-increment integer primary keys
|
|
99
|
-
- Missing timestamps
|
|
100
|
-
- Missing soft delete
|
|
101
|
-
- No explicit table name
|
|
102
|
-
- Relative imports
|