@manulz/nest-tools 1.1.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 +169 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +569 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.mjs +546 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/index.d.mts +141 -0
- package/dist/index.d.ts +141 -0
- package/dist/index.js +568 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +520 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# @manulz/nest-tools
|
|
2
|
+
|
|
3
|
+
> Developer utilities, Clean Architecture generator, and runtime helpers for NestJS projects.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@manulz/nest-tools)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 🚀 Features
|
|
11
|
+
|
|
12
|
+
- ⚡ **Interactive CLI**: Run without arguments for an interactive step-by-step wizard.
|
|
13
|
+
- 📦 **Resource Generator**: Create Module, Controller, and Service with a single command (configurable tests, flat structure, and dry-run).
|
|
14
|
+
- 🏛 **Clean Architecture / Hexagonal Generator**: Scaffold Domain Entities, Repository Interfaces, Application Use Cases, DTOs, and Infrastructure Controllers/Repositories in one go.
|
|
15
|
+
- 🩺 **Doctor Diagnostics**: Inspect your NestJS project for common issues, missing configs, or unimported modules.
|
|
16
|
+
- 🛠 **Runtime NestJS Helpers**:
|
|
17
|
+
- `@Public()` decorator for auth bypass.
|
|
18
|
+
- `@CurrentUser()` parameter decorator.
|
|
19
|
+
- `TransformResponseInterceptor` for standardized JSON envelopes.
|
|
20
|
+
- `PaginationQueryDto` and `createPaginatedResponse()` for turnkey pagination.
|
|
21
|
+
- 🔌 **Programmatic API**: Every feature is exported as a TypeScript module for use in CI, scripts, or build pipelines.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 📦 Installation
|
|
26
|
+
|
|
27
|
+
### Global or CLI via npx
|
|
28
|
+
```bash
|
|
29
|
+
# Run interactively without installing
|
|
30
|
+
npx @manulz/nest-tools
|
|
31
|
+
|
|
32
|
+
# Or install globally
|
|
33
|
+
npm install -g @manulz/nest-tools
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### In a NestJS Project (CLI + Runtime Helpers)
|
|
37
|
+
```bash
|
|
38
|
+
npm install @manulz/nest-tools
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 💻 CLI Usage
|
|
44
|
+
|
|
45
|
+
### 1. Interactive Mode
|
|
46
|
+
Simply run the command with no arguments:
|
|
47
|
+
```bash
|
|
48
|
+
nest-tools
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. Standard Resource Generation
|
|
52
|
+
Generates `module`, `controller`, and `service`:
|
|
53
|
+
```bash
|
|
54
|
+
nest-tools g users
|
|
55
|
+
nest-tools generate users --spec # include tests
|
|
56
|
+
nest-tools generate users --flat # flat layout
|
|
57
|
+
nest-tools generate users --dry-run # preview only
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 3. Clean Architecture / Hexagonal Module
|
|
61
|
+
Generates a complete DDD / Clean Architecture structure (`domain/`, `application/`, `infrastructure/`):
|
|
62
|
+
```bash
|
|
63
|
+
nest-tools hex products
|
|
64
|
+
nest-tools clean products
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Generated structure:
|
|
68
|
+
```text
|
|
69
|
+
src/products/
|
|
70
|
+
├── domain/
|
|
71
|
+
│ ├── entities/products.entity.ts
|
|
72
|
+
│ └── repositories/products.repository.interface.ts
|
|
73
|
+
├── application/
|
|
74
|
+
│ ├── dtos/create-products.dto.ts
|
|
75
|
+
│ ├── dtos/update-products.dto.ts
|
|
76
|
+
│ └── use-cases/
|
|
77
|
+
│ ├── create-products.use-case.ts
|
|
78
|
+
│ └── find-products.use-case.ts
|
|
79
|
+
├── infrastructure/
|
|
80
|
+
│ ├── controllers/products.controller.ts
|
|
81
|
+
│ └── repositories/in-memory-products.repository.ts
|
|
82
|
+
└── products.module.ts
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 4. Diagnostics (`doctor`)
|
|
86
|
+
Inspect your current project health:
|
|
87
|
+
```bash
|
|
88
|
+
nest-tools doctor
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 5. Config Init
|
|
92
|
+
Create a `nest-tools.json` file in your root:
|
|
93
|
+
```bash
|
|
94
|
+
nest-tools init
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 🛠 Programmatic API & Runtime Helpers
|
|
100
|
+
|
|
101
|
+
You can import generators, diagnostics, and NestJS runtime helpers in your TypeScript code:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import {
|
|
105
|
+
// Generators
|
|
106
|
+
generateResource,
|
|
107
|
+
generateCleanArchitecture,
|
|
108
|
+
// Diagnostics
|
|
109
|
+
runDoctor,
|
|
110
|
+
// Decorators
|
|
111
|
+
Public,
|
|
112
|
+
CurrentUser,
|
|
113
|
+
// Interceptors
|
|
114
|
+
TransformResponseInterceptor,
|
|
115
|
+
// Pagination
|
|
116
|
+
PaginationQueryDto,
|
|
117
|
+
createPaginatedResponse,
|
|
118
|
+
} from '@manulz/nest-tools';
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Decorators
|
|
122
|
+
```typescript
|
|
123
|
+
import { Controller, Get } from '@nestjs/common';
|
|
124
|
+
import { Public, CurrentUser } from '@manulz/nest-tools';
|
|
125
|
+
|
|
126
|
+
@Controller('users')
|
|
127
|
+
export class UsersController {
|
|
128
|
+
@Public()
|
|
129
|
+
@Get('health')
|
|
130
|
+
health() {
|
|
131
|
+
return { status: 'ok' };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@Get('me')
|
|
135
|
+
getProfile(@CurrentUser() user: any) {
|
|
136
|
+
return user;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Response Interceptor
|
|
142
|
+
```typescript
|
|
143
|
+
// In main.ts
|
|
144
|
+
import { TransformResponseInterceptor } from '@manulz/nest-tools';
|
|
145
|
+
|
|
146
|
+
app.useGlobalInterceptors(new TransformResponseInterceptor());
|
|
147
|
+
// Wraps output in: { statusCode: 200, success: true, data: ..., timestamp: '...' }
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Pagination Helper
|
|
151
|
+
```typescript
|
|
152
|
+
import { PaginationQueryDto, createPaginatedResponse } from '@manulz/nest-tools';
|
|
153
|
+
|
|
154
|
+
@Get()
|
|
155
|
+
async findAll(@Query() query: PaginationQueryDto) {
|
|
156
|
+
const [items, total] = await this.service.findAndCount({
|
|
157
|
+
skip: query.skip,
|
|
158
|
+
take: query.take,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return createPaginatedResponse(items, total, query.page, query.limit);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 📄 License
|
|
168
|
+
|
|
169
|
+
MIT © [Manulz](https://github.com/manulzweb)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|