@lenne.tech/cli 0.0.124 → 1.0.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/bin/lt +145 -14
- package/build/commands/claude/claude.js +25 -0
- package/build/commands/claude/install-skills.js +622 -0
- package/build/commands/config/config.js +25 -0
- package/build/commands/config/help.js +167 -0
- package/build/commands/config/init.js +143 -0
- package/build/commands/config/show.js +68 -0
- package/build/commands/fullstack/init.js +38 -16
- package/build/commands/server/add-property.js +199 -36
- package/build/commands/server/create.js +66 -4
- package/build/commands/server/module.js +150 -27
- package/build/commands/server/object.js +38 -22
- package/build/extensions/config.js +157 -0
- package/build/extensions/parse-properties.js +119 -0
- package/build/extensions/server.js +82 -47
- package/build/interfaces/lt-config.interface.js +3 -0
- package/build/templates/claude-skills/lt-cli/SKILL.md +272 -0
- package/build/templates/claude-skills/lt-cli/examples.md +542 -0
- package/build/templates/claude-skills/lt-cli/reference.md +506 -0
- package/build/templates/claude-skills/nest-server-generator/SKILL.md +2833 -0
- package/build/templates/claude-skills/nest-server-generator/examples.md +760 -0
- package/build/templates/claude-skills/nest-server-generator/reference.md +417 -0
- package/build/templates/nest-server-module/inputs/template-create.input.ts.ejs +1 -3
- package/build/templates/nest-server-module/inputs/template.input.ts.ejs +1 -1
- package/build/templates/nest-server-module/template.controller.ts.ejs +24 -13
- package/build/templates/nest-server-module/template.model.ts.ejs +2 -2
- package/build/templates/nest-server-module/template.module.ts.ejs +4 -0
- package/build/templates/nest-server-module/template.service.ts.ejs +6 -6
- package/build/templates/nest-server-object/template.object.ts.ejs +2 -2
- package/package.json +13 -11
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nest-server-generator-reference
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
description: Quick reference for ALL NestJS server development - from simple single commands to complex structure generation
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# NestJS Server Development Quick Reference
|
|
8
|
+
|
|
9
|
+
## Scope
|
|
10
|
+
|
|
11
|
+
**This skill handles ALL NestJS server development tasks:**
|
|
12
|
+
- ✅ Simple: Create single module, object, or add property
|
|
13
|
+
- ✅ Complex: Generate complete server structures from specifications
|
|
14
|
+
- ✅ Any `lt server` command
|
|
15
|
+
|
|
16
|
+
Use this skill for **ANY** NestJS/nest-server work, no matter how simple or complex.
|
|
17
|
+
|
|
18
|
+
## Specification Syntax
|
|
19
|
+
|
|
20
|
+
### Component Types
|
|
21
|
+
|
|
22
|
+
| Type | Syntax | Purpose |
|
|
23
|
+
|------|--------|---------|
|
|
24
|
+
| **SubObject** | `SubObject: Name // Desc` | Embedded data structure (no _id, no timestamps) |
|
|
25
|
+
| **Object** | `Object: Name\nProperties:\n- prop: type` | Base model for inheritance |
|
|
26
|
+
| **Module** | `Module: Name\nModel: Name\n- prop: type` | Full CRUD module with API |
|
|
27
|
+
|
|
28
|
+
### Property Syntax
|
|
29
|
+
|
|
30
|
+
| Pattern | Meaning | LT CLI Flag |
|
|
31
|
+
|---------|---------|-------------|
|
|
32
|
+
| `name: string` | Required string | `--prop-name-X name --prop-type-X string` |
|
|
33
|
+
| `age?: number` | Optional number | `--prop-name-X age --prop-type-X number --prop-nullable-X true` |
|
|
34
|
+
| `tags: string[]` | Array of strings | `--prop-name-X tags --prop-type-X string --prop-array-X true` |
|
|
35
|
+
| `status: ENUM (A, B)` | Enum property | `--prop-name-X status --prop-enum-X StatusEnum` |
|
|
36
|
+
| `owner: User` | Reference to module | `--prop-name-X owner --prop-type-X ObjectId --prop-reference-X User` |
|
|
37
|
+
| `address: Address` | Embedded object | `--prop-name-X address --prop-schema-X Address` |
|
|
38
|
+
| `items: Item[]` | Array of objects | `--prop-name-X items --prop-schema-X Item --prop-array-X true` |
|
|
39
|
+
| `doc: File` | File reference | `--prop-name-X doc --prop-type-X string` |
|
|
40
|
+
|
|
41
|
+
### Type Mapping
|
|
42
|
+
|
|
43
|
+
| Spec Type | TypeScript | MongoDB | CLI Type |
|
|
44
|
+
|-----------|-----------|---------|----------|
|
|
45
|
+
| `string` | string | String | string |
|
|
46
|
+
| `number` | number | Number | number |
|
|
47
|
+
| `boolean` | boolean | Boolean | boolean |
|
|
48
|
+
| `Date` | Date | Date | Date |
|
|
49
|
+
| `bigint` | bigint | Long | bigint |
|
|
50
|
+
| `File` | string | String | string |
|
|
51
|
+
| `ENUM(...)` | XxxEnum | String/Number | (use --prop-enum-X) |
|
|
52
|
+
| `OtherModule` | ObjectId ref | ObjectId | ObjectId + reference |
|
|
53
|
+
| `SubObject` | Embedded | Object | (use --prop-schema-X) |
|
|
54
|
+
|
|
55
|
+
## Execution Workflow
|
|
56
|
+
|
|
57
|
+
### Phase Checklist
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
☐ 1. Parse specification completely
|
|
61
|
+
☐ 2. Create comprehensive todo list
|
|
62
|
+
☐ 3. Create all SubObjects (dependency order)
|
|
63
|
+
☐ 4. Create all Objects
|
|
64
|
+
☐ 5. Create all Modules (dependency order)
|
|
65
|
+
☐ 6. Handle inheritance (manual edits)
|
|
66
|
+
☐ 7. Update all descriptions (ENGLISH (DEUTSCH))
|
|
67
|
+
☐ 8. Alphabetize all properties
|
|
68
|
+
☐ 9. Create enum files
|
|
69
|
+
☐ 10. Create API tests
|
|
70
|
+
☐ 11. Run tests
|
|
71
|
+
☐ 12. Verify & provide summary
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Dependency Order
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
1. SubObjects (if A uses B, create B first)
|
|
78
|
+
2. Objects (base models)
|
|
79
|
+
3. Modules (if A references B, create B first)
|
|
80
|
+
4. Circular refs (use addProp for second reference)
|
|
81
|
+
5. Inheritance updates
|
|
82
|
+
6. Enums
|
|
83
|
+
7. Tests
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Command Quick Reference
|
|
87
|
+
|
|
88
|
+
### Create New Server
|
|
89
|
+
```bash
|
|
90
|
+
lt server create <server-name>
|
|
91
|
+
# Alias: lt server c <server-name>
|
|
92
|
+
|
|
93
|
+
# Example
|
|
94
|
+
lt server create my-api
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**What it does**:
|
|
98
|
+
- Clones nest-server-starter template
|
|
99
|
+
- Configures package.json
|
|
100
|
+
- Sets up Swagger docs
|
|
101
|
+
- **Replaces ALL secrets** (`'SECRET_OR_PRIVATE_KEY...'` → unique random values)
|
|
102
|
+
- **Updates database names** (`nest-server-*` → `<project-name>-*`)
|
|
103
|
+
- Installs dependencies
|
|
104
|
+
- Optionally initializes git
|
|
105
|
+
|
|
106
|
+
**Post-creation verification**:
|
|
107
|
+
- Verify `src/config.env.ts` has no `SECRET_OR_PRIVATE_KEY` placeholders
|
|
108
|
+
- Verify mongoose.uri uses project name (e.g., `my-api-local` not `nest-server-local`)
|
|
109
|
+
- If using older CLI (<v0.0.126), run `lt server setConfigSecrets` manually
|
|
110
|
+
|
|
111
|
+
### Create SubObject
|
|
112
|
+
```bash
|
|
113
|
+
lt server object --name <Name> \
|
|
114
|
+
--prop-name-0 <name> --prop-type-0 <type> [modifiers] \
|
|
115
|
+
--prop-name-1 <name> --prop-type-1 <type> [modifiers]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Create Module
|
|
119
|
+
```bash
|
|
120
|
+
lt server module --name <Name> --controller <Rest|GraphQL|Both> \
|
|
121
|
+
--prop-name-0 <name> --prop-type-0 <type> [modifiers] \
|
|
122
|
+
--prop-name-1 <name> --prop-type-1 <type> [modifiers]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Add Properties
|
|
126
|
+
```bash
|
|
127
|
+
lt server addProp --type Module --element <Name> \
|
|
128
|
+
--prop-name-0 <name> --prop-type-0 <type> [modifiers]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Modifiers
|
|
132
|
+
|
|
133
|
+
| Modifier | Flag | Example |
|
|
134
|
+
|----------|------|---------|
|
|
135
|
+
| Optional | `--prop-nullable-X true` | `--prop-nullable-2 true` |
|
|
136
|
+
| Array | `--prop-array-X true` | `--prop-array-1 true` |
|
|
137
|
+
| Enum | `--prop-enum-X <EnumName>` | `--prop-enum-3 StatusEnum` |
|
|
138
|
+
| Schema | `--prop-schema-X <SchemaName>` | `--prop-schema-0 Address` |
|
|
139
|
+
| Reference | `--prop-reference-X <ModelName>` | `--prop-reference-1 User` |
|
|
140
|
+
|
|
141
|
+
## Description Format
|
|
142
|
+
|
|
143
|
+
**Rule**: `"ENGLISH_DESCRIPTION (DEUTSCHE_BESCHREIBUNG)"`
|
|
144
|
+
|
|
145
|
+
### Processing
|
|
146
|
+
|
|
147
|
+
| Input Comment | Output Description |
|
|
148
|
+
|---------------|-------------------|
|
|
149
|
+
| `// Street name` | `'Street name'` |
|
|
150
|
+
| `// Straße` | `'Street (Straße)'` |
|
|
151
|
+
| (no comment) | Create meaningful English description |
|
|
152
|
+
|
|
153
|
+
### Apply To
|
|
154
|
+
- Model property `@UnifiedField({ description: '...' })`
|
|
155
|
+
- Input property `@UnifiedField({ description: '...' })`
|
|
156
|
+
- Output property `@UnifiedField({ description: '...' })`
|
|
157
|
+
|
|
158
|
+
## Inheritance Handling
|
|
159
|
+
|
|
160
|
+
### Model Extension
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
// FROM (generated):
|
|
164
|
+
import { CoreModel } from '@lenne.tech/nest-server';
|
|
165
|
+
export class ChildModel extends CoreModel { ... }
|
|
166
|
+
|
|
167
|
+
// TO (manual edit):
|
|
168
|
+
import { ParentModel } from '../../common/objects/parent/parent.model';
|
|
169
|
+
export class ChildModel extends ParentModel { ... }
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Input Extension
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
// child-create.input.ts
|
|
176
|
+
// MUST include:
|
|
177
|
+
// 1. ALL required fields from parent's CreateInput
|
|
178
|
+
// 2. ALL required fields from child model
|
|
179
|
+
// 3. Optional fields from both (optional in UpdateInput)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Core Models (no changes needed)
|
|
183
|
+
- `CoreModel`
|
|
184
|
+
- `CorePersisted`
|
|
185
|
+
- Any @lenne.tech/nest-server base class
|
|
186
|
+
|
|
187
|
+
## Enum File Template
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// src/server/common/enums/<name>.enum.ts
|
|
191
|
+
export enum <Name>Enum {
|
|
192
|
+
VALUE_ONE = 'VALUE_ONE',
|
|
193
|
+
VALUE_TWO = 'VALUE_TWO',
|
|
194
|
+
VALUE_THREE = 'VALUE_THREE',
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Naming
|
|
199
|
+
- **File**: `kebab-case.enum.ts` → `user-status.enum.ts`
|
|
200
|
+
- **Enum**: `PascalCaseEnum` → `UserStatusEnum`
|
|
201
|
+
- **Values**: `UPPER_SNAKE_CASE` → `ACTIVE`, `PENDING`
|
|
202
|
+
|
|
203
|
+
## API Test Template
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// test/<module>/<module>.controller.test.ts
|
|
207
|
+
import { testHelper } from '@lenne.tech/nest-server';
|
|
208
|
+
|
|
209
|
+
describe('<Module> Controller', () => {
|
|
210
|
+
let testUser;
|
|
211
|
+
let created<Model>;
|
|
212
|
+
|
|
213
|
+
beforeAll(async () => {
|
|
214
|
+
testUser = await testHelper.createTestUser({ roles: ['admin'] });
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
afterAll(async () => {
|
|
218
|
+
if (created<Model>) await testHelper.delete('<modules>', created<Model>.id);
|
|
219
|
+
await testHelper.deleteTestUser(testUser.id);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('should create with required fields', async () => { /* ... */ });
|
|
223
|
+
it('should fail without required fields', async () => { /* ... */ });
|
|
224
|
+
it('should get all', async () => { /* ... */ });
|
|
225
|
+
it('should get by id', async () => { /* ... */ });
|
|
226
|
+
it('should update', async () => { /* ... */ });
|
|
227
|
+
it('should delete', async () => { /* ... */ });
|
|
228
|
+
it('should fail without auth', async () => { /* ... */ });
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Test Coverage
|
|
233
|
+
- ✅ Create (valid data)
|
|
234
|
+
- ✅ Create (missing required - fail)
|
|
235
|
+
- ✅ Find all
|
|
236
|
+
- ✅ Find by ID
|
|
237
|
+
- ✅ Update
|
|
238
|
+
- ✅ Delete
|
|
239
|
+
- ✅ Authorization (fail without auth)
|
|
240
|
+
- ✅ Required fields validation
|
|
241
|
+
|
|
242
|
+
## Common Patterns
|
|
243
|
+
|
|
244
|
+
### Pattern 1: Simple Module
|
|
245
|
+
```
|
|
246
|
+
Module: Product
|
|
247
|
+
Model: Product
|
|
248
|
+
- name: string
|
|
249
|
+
- price: number
|
|
250
|
+
```
|
|
251
|
+
→ `lt server module --name Product --controller Both --prop-name-0 name --prop-type-0 string --prop-name-1 price --prop-type-1 number`
|
|
252
|
+
|
|
253
|
+
### Pattern 2: Module with Reference
|
|
254
|
+
```
|
|
255
|
+
Module: Order
|
|
256
|
+
Model: Order
|
|
257
|
+
- customer: User
|
|
258
|
+
- total: number
|
|
259
|
+
```
|
|
260
|
+
→ `lt server module --name Order --controller Both --prop-name-0 customer --prop-type-0 ObjectId --prop-reference-0 User --prop-name-1 total --prop-type-1 number`
|
|
261
|
+
|
|
262
|
+
### Pattern 3: Module with Embedded Object
|
|
263
|
+
```
|
|
264
|
+
SubObject: Address
|
|
265
|
+
- street: string
|
|
266
|
+
- city: string
|
|
267
|
+
|
|
268
|
+
Module: Company
|
|
269
|
+
Model: Company
|
|
270
|
+
- name: string
|
|
271
|
+
- address: Address
|
|
272
|
+
```
|
|
273
|
+
→ Create Address first, then Company with `--prop-schema-X Address`
|
|
274
|
+
|
|
275
|
+
### Pattern 4: Module with Enum Array
|
|
276
|
+
```
|
|
277
|
+
Module: User
|
|
278
|
+
Model: User
|
|
279
|
+
- name: string
|
|
280
|
+
- roles: ENUM (ADMIN, USER, GUEST)[]
|
|
281
|
+
```
|
|
282
|
+
→ `--prop-name-1 roles --prop-enum-1 RoleEnum --prop-array-1 true`
|
|
283
|
+
|
|
284
|
+
### Pattern 5: Inheritance
|
|
285
|
+
```
|
|
286
|
+
Object: BaseProfile
|
|
287
|
+
Properties:
|
|
288
|
+
- name: string
|
|
289
|
+
- email: string
|
|
290
|
+
|
|
291
|
+
Module: UserProfile
|
|
292
|
+
Model: UserProfile
|
|
293
|
+
Extends: BaseProfile
|
|
294
|
+
- username: string
|
|
295
|
+
```
|
|
296
|
+
→ Create BaseProfile object, create UserProfile module, manually update to extend BaseProfile
|
|
297
|
+
|
|
298
|
+
### Pattern 6: Circular References
|
|
299
|
+
```
|
|
300
|
+
Module: Author
|
|
301
|
+
- books: Book[]
|
|
302
|
+
|
|
303
|
+
Module: Book
|
|
304
|
+
- author: Author
|
|
305
|
+
```
|
|
306
|
+
→ Create Author, create Book with author ref, use addProp to add books to Author
|
|
307
|
+
|
|
308
|
+
## Troubleshooting
|
|
309
|
+
|
|
310
|
+
| Issue | Solution |
|
|
311
|
+
|-------|----------|
|
|
312
|
+
| Missing imports | Add manually: `import { Ref } from '@lenne.tech/nest-server'` |
|
|
313
|
+
| CreateInput validation fails | Add parent's required fields to child's CreateInput |
|
|
314
|
+
| Enum errors | Create enum file in `src/server/common/enums/` |
|
|
315
|
+
| Test fails (required fields) | Check CreateInput for all required fields |
|
|
316
|
+
| Circular dependency | Use `addProp` for second reference |
|
|
317
|
+
| Properties not alphabetical | Reorder manually in all files |
|
|
318
|
+
| TypeScript errors after inheritance | Check imports and extend statement |
|
|
319
|
+
|
|
320
|
+
## Verification Checklist
|
|
321
|
+
|
|
322
|
+
Final checks before completing:
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
☐ All SubObjects created
|
|
326
|
+
☐ All Objects created
|
|
327
|
+
☐ All Modules created
|
|
328
|
+
☐ Properties in alphabetical order
|
|
329
|
+
☐ Descriptions: "ENGLISH (DEUTSCH)" format
|
|
330
|
+
☐ Inheritance correctly implemented
|
|
331
|
+
☐ CreateInputs have all required fields (parent + model)
|
|
332
|
+
☐ Enum files created in src/server/common/enums/
|
|
333
|
+
☐ API tests created for all modules
|
|
334
|
+
☐ Tests cover CRUD operations
|
|
335
|
+
☐ Tests verify authorization
|
|
336
|
+
☐ Tests verify required fields
|
|
337
|
+
☐ All tests pass
|
|
338
|
+
☐ No TypeScript errors
|
|
339
|
+
☐ Lint passes
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## File Structure
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
src/server/
|
|
346
|
+
├── modules/
|
|
347
|
+
│ ├── <module-name>/
|
|
348
|
+
│ │ ├── <module-name>.model.ts
|
|
349
|
+
│ │ ├── <module-name>.service.ts
|
|
350
|
+
│ │ ├── <module-name>.controller.ts (if Rest/Both)
|
|
351
|
+
│ │ ├── <module-name>.resolver.ts (if GraphQL/Both)
|
|
352
|
+
│ │ ├── <module-name>.module.ts
|
|
353
|
+
│ │ ├── inputs/
|
|
354
|
+
│ │ │ ├── <module-name>.input.ts
|
|
355
|
+
│ │ │ └── <module-name>-create.input.ts
|
|
356
|
+
│ │ └── outputs/
|
|
357
|
+
│ │ └── find-and-count-<module-name>s-result.output.ts
|
|
358
|
+
│ └── ...
|
|
359
|
+
└── common/
|
|
360
|
+
├── objects/
|
|
361
|
+
│ ├── <object-name>/
|
|
362
|
+
│ │ ├── <object-name>.object.ts
|
|
363
|
+
│ │ ├── <object-name>.input.ts
|
|
364
|
+
│ │ └── <object-name>-create.input.ts
|
|
365
|
+
│ └── ...
|
|
366
|
+
└── enums/
|
|
367
|
+
├── <enum-name>.enum.ts
|
|
368
|
+
└── ...
|
|
369
|
+
|
|
370
|
+
test/
|
|
371
|
+
├── <module-name>/
|
|
372
|
+
│ ├── <module-name>.controller.test.ts
|
|
373
|
+
│ └── <module-name>.resolver.test.ts
|
|
374
|
+
└── ...
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## Best Practices Summary
|
|
378
|
+
|
|
379
|
+
1. ✅ **Plan before executing** - Analyze full specification first
|
|
380
|
+
2. ✅ **Create dependencies first** - SubObjects → Objects → Modules
|
|
381
|
+
3. ✅ **Follow naming conventions** - PascalCase for types, camelCase for properties
|
|
382
|
+
4. ✅ **Order matters** - Alphabetical properties, dependency-ordered creation
|
|
383
|
+
5. ✅ **Describe thoroughly** - "ENGLISH (DEUTSCH)" everywhere
|
|
384
|
+
6. ✅ **Test comprehensively** - All CRUD + auth + validation
|
|
385
|
+
7. ✅ **Clean up tests** - Delete test data in afterAll
|
|
386
|
+
8. ✅ **Commit incrementally** - After SubObjects, Modules, Tests
|
|
387
|
+
9. ✅ **Verify before finishing** - Run checklist, ensure tests pass
|
|
388
|
+
10. ✅ **Report observations** - Note data structure issues/improvements
|
|
389
|
+
|
|
390
|
+
## Quick Start
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
# 1. Receive specification
|
|
394
|
+
# 2. Parse and create todo list
|
|
395
|
+
# 3. Execute commands in order:
|
|
396
|
+
|
|
397
|
+
# SubObjects
|
|
398
|
+
lt server object --name Address --prop-name-0 street --prop-type-0 string ...
|
|
399
|
+
|
|
400
|
+
# Modules
|
|
401
|
+
lt server module --name User --controller Both --prop-name-0 email --prop-type-0 string ...
|
|
402
|
+
|
|
403
|
+
# Enums
|
|
404
|
+
# Create files in src/server/common/enums/
|
|
405
|
+
|
|
406
|
+
# Tests
|
|
407
|
+
# Create test files for each module
|
|
408
|
+
|
|
409
|
+
# 4. Verify and report
|
|
410
|
+
npm test
|
|
411
|
+
npm run lint
|
|
412
|
+
# Provide summary
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
**Remember**: This skill handles COMPLETE structure generation, not individual commands. Always process the full specification systematically and provide comprehensive summaries.
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Restricted, RoleEnum, UnifiedField } from '@lenne.tech/nest-server';
|
|
2
2
|
import { InputType } from '@nestjs/graphql';
|
|
3
|
-
|
|
4
|
-
import { <%= props.namePascal %>Input } from './<%= props.nameKebab %>.input';
|
|
5
|
-
|
|
3
|
+
import { <%= props.namePascal %>Input } from './<%= props.nameKebab %>.input';<%- props.imports %>
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* <%= props.namePascal %> create input
|
|
@@ -14,39 +14,50 @@ export class <%= props.namePascal %>Controller {
|
|
|
14
14
|
|
|
15
15
|
constructor(protected readonly <%= props.nameCamel %>Service: <%= props.namePascal %>Service) {}
|
|
16
16
|
|
|
17
|
-
@Post()
|
|
18
|
-
@Roles(RoleEnum.ADMIN)
|
|
19
17
|
@ApiOkResponse({ type: <%= props.namePascal %> })
|
|
18
|
+
@Post()
|
|
19
|
+
@Roles(RoleEnum.S_USER)
|
|
20
20
|
async create(@Body() input: <%= props.namePascal %>CreateInput): Promise<<%= props.namePascal %>> {
|
|
21
21
|
return await this.<%= props.nameCamel %>Service.create(input);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
@
|
|
25
|
-
@
|
|
24
|
+
@ApiOkResponse({ description: 'Find and count <%= props.namePascal %>' })
|
|
25
|
+
@Get('find-and-count')
|
|
26
|
+
@Roles(RoleEnum.S_USER)
|
|
27
|
+
async findAndCount(@Body() filterArgs: FilterArgs): Promise<{ items: <%= props.namePascal %>[]; totalCount: number }> {
|
|
28
|
+
return await this.<%= props.nameCamel %>Service.findAndCount(filterArgs);
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
@ApiOkResponse({ isArray: true, type: <%= props.namePascal %> })
|
|
32
|
+
@Get()
|
|
33
|
+
@Roles(RoleEnum.S_USER)
|
|
27
34
|
async get(@Body() filterArgs: FilterArgs): Promise<<%= props.namePascal %>[]> {
|
|
28
35
|
return await this.<%= props.nameCamel %>Service.find(filterArgs);
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
@Get(':id')
|
|
32
|
-
@Roles(RoleEnum.ADMIN)
|
|
33
38
|
@ApiOkResponse({ type: <%= props.namePascal %> })
|
|
39
|
+
@Get(':id')
|
|
40
|
+
@Roles(RoleEnum.S_USER)
|
|
34
41
|
async getById(@Param('id') id: string): Promise<<%= props.namePascal %>> {
|
|
35
|
-
return await this.<%= props.nameCamel %>Service.findOne({filterQuery: { _id: id }})
|
|
42
|
+
return await this.<%= props.nameCamel %>Service.findOne({filterQuery: { _id: id }});
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
@Put(':id')
|
|
39
|
-
@Roles(RoleEnum.ADMIN)
|
|
40
45
|
@ApiOkResponse({ type: <%= props.namePascal %> })
|
|
46
|
+
@Put(':id')
|
|
47
|
+
@Roles(RoleEnum.S_USER)
|
|
41
48
|
async update(@Param('id') id: string, @Body() input: <%= props.namePascal %>Input): Promise<<%= props.namePascal %>> {
|
|
42
|
-
return await this.<%= props.nameCamel %>Service.update(id, input
|
|
49
|
+
return await this.<%= props.nameCamel %>Service.update(id, input, {
|
|
50
|
+
roles: [RoleEnum.ADMIN, RoleEnum.S_CREATOR],
|
|
51
|
+
});
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
@Delete(':id')
|
|
46
|
-
@Roles(RoleEnum.ADMIN)
|
|
47
54
|
@ApiOkResponse({ type: <%= props.namePascal %> })
|
|
55
|
+
@Delete(':id')
|
|
56
|
+
@Roles(RoleEnum.S_USER)
|
|
48
57
|
async delete(@Param('id') id: string): Promise<<%= props.namePascal %>> {
|
|
49
|
-
return await this.<%= props.nameCamel %>Service.delete(id
|
|
58
|
+
return await this.<%= props.nameCamel %>Service.delete(id, {
|
|
59
|
+
roles: [RoleEnum.ADMIN, RoleEnum.S_CREATOR],
|
|
60
|
+
});
|
|
50
61
|
}
|
|
51
62
|
|
|
52
63
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Restricted, RoleEnum, equalIds
|
|
1
|
+
import { Restricted, RoleEnum, equalIds<% if (props.mappings.includes('mapClasses')) { %>, mapClasses<% } %>, UnifiedField} from '@lenne.tech/nest-server';
|
|
2
2
|
<% if (props.isGql) { %>
|
|
3
3
|
import { ObjectType } from '@nestjs/graphql';
|
|
4
4
|
<% } %>
|
|
5
|
-
import { Schema as MongooseSchema,
|
|
5
|
+
import { Schema as MongooseSchema, SchemaFactory } from '@nestjs/mongoose';
|
|
6
6
|
import { Document, Schema } from 'mongoose';<%- props.imports %>
|
|
7
7
|
|
|
8
8
|
import { PersistenceModel } from '../../common/models/persistence.model';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ConfigService } from '@lenne.tech/nest-server';
|
|
2
2
|
import { Module, forwardRef } from '@nestjs/common';
|
|
3
3
|
import { MongooseModule } from '@nestjs/mongoose';
|
|
4
|
+
<% if ((props.controller === 'GraphQL') || (props.controller === 'Both')) { -%>
|
|
4
5
|
import { PubSub } from 'graphql-subscriptions';
|
|
6
|
+
<% } -%>
|
|
5
7
|
|
|
6
8
|
import { UserModule } from '../user/user.module';
|
|
7
9
|
import { <%= props.namePascal %>, <%= props.namePascal %>Schema } from './<%= props.nameKebab %>.model';
|
|
@@ -28,10 +30,12 @@ import { <%= props.namePascal %>Controller } from './<%= props.nameKebab %>.cont
|
|
|
28
30
|
<%= props.namePascal %>Resolver,
|
|
29
31
|
<% } -%>
|
|
30
32
|
<%= props.namePascal %>Service,
|
|
33
|
+
<% if ((props.controller === 'GraphQL') || (props.controller === 'Both')) { -%>
|
|
31
34
|
{
|
|
32
35
|
provide: 'PUB_SUB',
|
|
33
36
|
useValue: new PubSub(),
|
|
34
37
|
},
|
|
38
|
+
<% } -%>
|
|
35
39
|
],
|
|
36
40
|
})
|
|
37
41
|
export class <%= props.namePascal %>Module {}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConfigService, CrudService, ServiceOptions, assignPlain } from '@lenne.tech/nest-server';
|
|
2
2
|
import { Inject, Injectable, NotFoundException } from '@nestjs/common';
|
|
3
3
|
import { InjectModel } from '@nestjs/mongoose';
|
|
4
|
-
import { PubSub } from 'graphql-subscriptions';
|
|
5
|
-
import { Model } from 'mongoose';
|
|
4
|
+
<% if (props.isGql) { %>import { PubSub } from 'graphql-subscriptions';
|
|
5
|
+
<% } %>import { Model } from 'mongoose';
|
|
6
6
|
|
|
7
7
|
import { <%= props.namePascal %>Input } from './inputs/<%= props.nameKebab %>.input';
|
|
8
8
|
import { <%= props.namePascal %>CreateInput } from './inputs/<%= props.nameKebab %>-create.input';
|
|
@@ -33,8 +33,8 @@ export class <%= props.namePascal %>Service extends CrudService<<%= props.namePa
|
|
|
33
33
|
constructor(
|
|
34
34
|
protected override readonly configService: ConfigService,
|
|
35
35
|
@InjectModel('<%= props.namePascal %>') protected readonly <%= props.nameCamel %>Model: Model<<%= props.namePascal %>Document>,
|
|
36
|
-
@Inject('PUB_SUB') protected readonly pubSub: PubSub,
|
|
37
|
-
) {
|
|
36
|
+
<% if (props.isGql) { %> @Inject('PUB_SUB') protected readonly pubSub: PubSub,
|
|
37
|
+
<% } %> ) {
|
|
38
38
|
super({ configService, mainDbModel: <%= props.nameCamel %>Model, mainModelConstructor: <%= props.namePascal %> });
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -49,12 +49,12 @@ export class <%= props.namePascal %>Service extends CrudService<<%= props.namePa
|
|
|
49
49
|
override async create(input: <%= props.namePascal %>CreateInput, serviceOptions?: ServiceOptions): Promise<<%= props.namePascal %>> {
|
|
50
50
|
// Get new <%= props.namePascal %>
|
|
51
51
|
const created<%= props.namePascal %> = await super.create(input, serviceOptions);
|
|
52
|
-
|
|
52
|
+
<% if (props.isGql) { %>
|
|
53
53
|
// Inform subscriber
|
|
54
54
|
if (serviceOptions?.pubSub === undefined || serviceOptions.pubSub) {
|
|
55
55
|
await this.pubSub.publish('<%= props.nameCamel %>Created', <%= props.namePascal %>.map(created<%= props.namePascal %>));
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
<% } %>
|
|
58
58
|
// Return created <%= props.namePascal %>
|
|
59
59
|
return created<%= props.namePascal %>;
|
|
60
60
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CoreModel, Restricted, RoleEnum
|
|
1
|
+
import { CoreModel, Restricted, RoleEnum<% if (props.mappings.includes('mapClasses')) { %>, mapClasses<% } %>, UnifiedField } from '@lenne.tech/nest-server';
|
|
2
2
|
import { ObjectType } from '@nestjs/graphql';
|
|
3
|
-
import { Schema as MongooseSchema,
|
|
3
|
+
import { Schema as MongooseSchema, SchemaFactory } from '@nestjs/mongoose';
|
|
4
4
|
import { Document } from 'mongoose';<%- props.imports %>
|
|
5
5
|
|
|
6
6
|
import { User } from '../../../modules/user/user.model';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/cli",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "lenne.Tech CLI: lt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lenne.Tech",
|
|
@@ -49,34 +49,36 @@
|
|
|
49
49
|
"bin"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@aws-sdk/client-s3": "3.
|
|
53
|
-
"@lenne.tech/cli-plugin-helper": "0.0.
|
|
52
|
+
"@aws-sdk/client-s3": "3.926.0",
|
|
53
|
+
"@lenne.tech/cli-plugin-helper": "0.0.14",
|
|
54
|
+
"@types/lodash": "4.17.20",
|
|
54
55
|
"bcrypt": "6.0.0",
|
|
55
56
|
"find-file-up": "2.0.1",
|
|
56
57
|
"glob": "11.0.3",
|
|
57
58
|
"gluegun": "5.2.0",
|
|
58
59
|
"js-sha256": "0.11.1",
|
|
60
|
+
"lodash": "4.17.21",
|
|
59
61
|
"open": "10.2.0",
|
|
60
|
-
"
|
|
61
|
-
"ts-morph": "27.0.0",
|
|
62
|
+
"ts-morph": "27.0.2",
|
|
62
63
|
"ts-node": "10.9.2",
|
|
63
64
|
"typescript": "5.9.3"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"@lenne.tech/eslint-config-ts": "2.1.
|
|
67
|
+
"@lenne.tech/eslint-config-ts": "2.1.4",
|
|
67
68
|
"@lenne.tech/npm-package-helper": "0.0.12",
|
|
68
69
|
"@types/jest": "30.0.0",
|
|
69
|
-
"@types/node": "24.
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "8.46.
|
|
71
|
-
"@typescript-eslint/parser": "8.46.
|
|
72
|
-
"eslint": "9.
|
|
70
|
+
"@types/node": "24.10.0",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "8.46.3",
|
|
72
|
+
"@typescript-eslint/parser": "8.46.3",
|
|
73
|
+
"eslint": "9.39.1",
|
|
73
74
|
"eslint-config-prettier": "10.1.8",
|
|
74
75
|
"husky": "9.1.7",
|
|
75
76
|
"jest": "30.2.0",
|
|
76
77
|
"path-exists-cli": "2.0.0",
|
|
77
78
|
"prettier": "3.6.2",
|
|
78
79
|
"pretty-quick": "4.2.2",
|
|
79
|
-
"rimraf": "6.0
|
|
80
|
+
"rimraf": "6.1.0",
|
|
81
|
+
"standard-version": "9.5.0",
|
|
80
82
|
"ts-jest": "29.4.5"
|
|
81
83
|
},
|
|
82
84
|
"overrides": {
|