@alevnyacow/nzmt 0.39.2 → 0.39.4
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 +34 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,35 +164,35 @@ export default async function Page() {
|
|
|
164
164
|
|
|
165
165
|
## Initialization
|
|
166
166
|
|
|
167
|
-
| Command
|
|
168
|
-
|
|
169
|
-
| `npx nzmt init`
|
|
167
|
+
| Command | Scaffolding result | Options |
|
|
168
|
+
| --------------- | ------------------ | ------------------------------------------------------------------------------------------------------------- |
|
|
169
|
+
| `npx nzmt init` | **init**ialization | pass `prismaClientPath:` to work with Prisma. E.g. `npx nzmt init prismaClientPath:@/generated/prisma/client` |
|
|
170
170
|
|
|
171
171
|
## Complex scaffolding
|
|
172
172
|
|
|
173
|
-
| Command
|
|
174
|
-
|
|
175
|
-
| `npx nzmt crud-api <name>`
|
|
176
|
-
| `npx nzmt crud-service <name>` | CRUD via Server Actions (no Controllers, API Routes and React Query hooks).
|
|
177
|
-
| `npx nzmt se <name>`
|
|
178
|
-
| `npx nzmt rq`
|
|
173
|
+
| Command | Scaffolding result |
|
|
174
|
+
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
175
|
+
| `npx nzmt crud-api <name>` | CRUD via Server Actions and React Query hooks. |
|
|
176
|
+
| `npx nzmt crud-service <name>` | CRUD via Server Actions (no Controllers, API Routes and React Query hooks). |
|
|
177
|
+
| `npx nzmt se <name>` | **s**tored **e**ntity: entity + store (contracts linked). |
|
|
178
|
+
| `npx nzmt rq` | API **r**outes and React **q**ueries for all of your controllers. This command will also remove endpoints which don't exist anymore with according React query hooks |
|
|
179
179
|
|
|
180
180
|
## Primary server modules scaffolding
|
|
181
181
|
|
|
182
|
-
| Command
|
|
183
|
-
|
|
184
|
-
| `npx nzmt e <name>` | **e**ntity
|
|
185
|
-
| `npx nzmt vo <name>` | **v**alue **o**bject
|
|
186
|
-
| `npx nzmt cs <name>`
|
|
187
|
-
| `npx nzmt s <name>` | **s**ervice
|
|
188
|
-
| `npx nzmt c <name>` | **c**ontroller
|
|
182
|
+
| Command | Scaffolding result | Options |
|
|
183
|
+
| -------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
184
|
+
| `npx nzmt e <name>` | **e**ntity | |
|
|
185
|
+
| `npx nzmt vo <name>` | **v**alue **o**bject | |
|
|
186
|
+
| `npx nzmt cs <name>` | **c**ustom **s**tore (all schemas are `z.object({})`) | |
|
|
187
|
+
| `npx nzmt s <name>` | **s**ervice | `i:UserStore,Logger` will automatically inject `UserStore` and `Logger`. E.g. `npx nzmt s shop i:UserStore,ProductStore` will create `ShopService` with already injected `UserStore` and `ProductStore` |
|
|
188
|
+
| `npx nzmt c <name>` | **c**ontroller | `i:UserService` will automatically inject `UserService`. `Logger` and `Guards` are injected by default regardless of `i:` option |
|
|
189
189
|
|
|
190
190
|
## Auxiliary server modules scaffolding
|
|
191
191
|
|
|
192
|
-
| Command
|
|
193
|
-
|
|
194
|
-
| `npx nzmt p <name>`
|
|
195
|
-
| `npx nzmt i <name>`
|
|
192
|
+
| Command | Scaffolding result |
|
|
193
|
+
| ------------------- | ------------------------- |
|
|
194
|
+
| `npx nzmt p <name>` | **p**rovider |
|
|
195
|
+
| `npx nzmt i <name>` | **i**nfrastructure module |
|
|
196
196
|
|
|
197
197
|
|
|
198
198
|
# How to implement your own methods
|
|
@@ -299,22 +299,22 @@ Once you done implementing controller methods, just run `nmx nzmt rq`. This comm
|
|
|
299
299
|
|
|
300
300
|
`NZMT` combines the best of both worlds in one package while staying in plain Next.js:
|
|
301
301
|
|
|
302
|
-
| Feature
|
|
303
|
-
|
|
|
304
|
-
|
|
|
305
|
-
|
|
|
306
|
-
|
|
|
307
|
-
|
|
|
308
|
-
|
|
|
309
|
-
|
|
|
310
|
-
|
|
|
311
|
-
|
|
|
312
|
-
| Code ownership
|
|
302
|
+
| Feature | NZMT | tRPC | Nest |
|
|
303
|
+
| ---------------------- | --------------------------------------------- | ------ | ------------------------------- |
|
|
304
|
+
| Architecture | contract-first, domain-focused | ❌ | module-centric, tightly coupled |
|
|
305
|
+
| Learning curve | Medium | Low | High |
|
|
306
|
+
| Type safety | ✅ - including run-time checks out of the box | ✅ | ⚠️ |
|
|
307
|
+
| Scaffolding | ✅ - production-ready full-stack | ❌ | ⚠️ |
|
|
308
|
+
| Boilerplate | ✅ - Low | ✅ | ❌ - High |
|
|
309
|
+
| No framework lock-in | ✅ | ✅ | ❌ |
|
|
310
|
+
| Single source of truth | ✅ (schemas) | ⚠️ | ❌ |
|
|
311
|
+
| Time to first feature | ✅ instant full-stack | ⚡ fast | 🐢 slow |
|
|
312
|
+
| Code ownership | ✅ full (generated, editable) | ✅ | ⚠️ (framework patterns) |
|
|
313
313
|
|
|
314
314
|
|
|
315
315
|
## What does domain-focused mean?
|
|
316
316
|
|
|
317
|
-
NZMT puts your business domain first. Entities drive the architecture, so backend and frontend stay consistent
|
|
317
|
+
NZMT puts your business domain first. Entities drive the architecture, so backend and frontend stay consistent.
|
|
318
318
|
|
|
319
319
|
## What does contract-first mean?
|
|
320
320
|
|
|
@@ -324,9 +324,9 @@ The behavior of all server modules in NZMT is governed by Zod schemas. Function
|
|
|
324
324
|
|
|
325
325
|
Yes — everything is fully editable, including configuration. Think of NZMT as a shadcn-style approach for full-stack: scaffold first, then fully own the code. Moreover, in most of the cases your changes are preserved on subsequent generations. For example, if you modify a generated query and run `npx nzmt rq` later, your edits stay intact.
|
|
326
326
|
|
|
327
|
-
## Do I really need to understand DI and other fancy concepts to use NZMT?
|
|
327
|
+
## Do I really need to understand DI and other fancy concepts to use NZMT effectively?
|
|
328
328
|
|
|
329
|
-
|
|
329
|
+
Not really. NZMT handles dependency injection (DI) for you using `inversifyjs`. You don’t need to set it up manually.
|
|
330
330
|
To get an instance of a service anywhere in your server code, just use:
|
|
331
331
|
|
|
332
332
|
```tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.4",
|
|
4
4
|
"description": "Next Zod Modules Toolkit",
|
|
5
5
|
"keywords": ["next", "full-stack", "server", "backend", "cli", "scaffolding", "zod", "rest", "contract programming", "contract-first", "react-query", "ddd", "domain-driven"],
|
|
6
6
|
"repository": {
|