@alevnyacow/nzmt 0.20.2 → 0.20.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 +16 -43
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,70 +9,45 @@
|
|
|
9
9
|
<img src='https://img.shields.io/bundlephobia/minzip/%40alevnyacow/nzmt'></img>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
|
-
Scaffold full-stack modules in Next.js in seconds with **Next Zod Modules Toolkit (NZMT)**.
|
|
12
|
+
Scaffold full-stack modules in Next.js in seconds with **Next Zod Modules Toolkit (NZMT)**.
|
|
13
13
|
|
|
14
|
-
Get
|
|
14
|
+
Get a DDD-inspired architecture with a contract-first approach out of the box. NZMT also comes with useful infrastructure like DI, logging, unified errors, and endpoint guards.
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Batteries included!
|
|
17
17
|
|
|
18
|
-
# TL;DR
|
|
19
|
-
|
|
20
|
-
1\. initialize NZMT once
|
|
21
|
-
|
|
22
|
-
2\. run the scaffolder (e.g. `npx nzmt crud-api user`)
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
# TL;DR
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
Initialize NZMT once, run the scaffolder, and tweak a few files to get a production-ready backend usable via Server Actions with ready-to-use React Query hooks.
|
|
27
22
|
|
|
28
23
|
# Quick start with Prisma
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
Assuming you have
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
- `Next.js` project with a generated `Prisma` client
|
|
28
|
+
- some `User` schema in your `Prisma` client
|
|
29
|
+
- enabled `experimentalDecorators` and `emitDecoratorMetadata` in `compilerOptions` section of `tsconfig.json`
|
|
30
|
+
- configured `@tanstack/react-query`
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
## Setup
|
|
35
33
|
|
|
36
34
|
```bash
|
|
35
|
+
# install NZMT and peer dependencies
|
|
37
36
|
npm i inversify zod reflect-metadata @alevnyacow/nzmt
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### 2. Enable decorators in tsconfig.json
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
"compilerOptions": {
|
|
45
|
-
"experimentalDecorators": true,
|
|
46
|
-
"emitDecoratorMetadata": true
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### 3. Initialize
|
|
52
|
-
|
|
53
|
-
```bash
|
|
38
|
+
# initialize NZMT with absolute prisma client path
|
|
54
39
|
npx nzmt init prismaClientPath:@/generated/prisma/client
|
|
55
40
|
```
|
|
56
41
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- `nzmt.config.json` file
|
|
60
|
-
- DI setup
|
|
61
|
-
- infrastructure helpers
|
|
42
|
+
Then plug your `Prisma` adapter in scaffolded `/server/infrastructure/prisma/client.ts` file.
|
|
62
43
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Edit scaffolded `/server/infrastructure/prisma/client.ts` file
|
|
66
|
-
|
|
67
|
-
## Making full-stack CRUD for `User` entity with React queries and Server Actions
|
|
68
|
-
|
|
69
|
-
Assuming you have some `User` prisma schema.
|
|
44
|
+
## Scaffolding CRUD operations for `User`
|
|
70
45
|
|
|
71
46
|
```bash
|
|
72
47
|
npx nzmt crud-api user
|
|
73
48
|
```
|
|
74
49
|
|
|
75
|
-
This command
|
|
50
|
+
This command scaffolds:
|
|
76
51
|
|
|
77
52
|
- `User` entity
|
|
78
53
|
- `UserStore` (with Prisma + RAM implementations)
|
|
@@ -81,8 +56,6 @@ This command generates:
|
|
|
81
56
|
- `API routes` for UserController endpoints
|
|
82
57
|
- `React Query hooks` for fetching UserController from client-side
|
|
83
58
|
|
|
84
|
-
Everything is wired automatically via DI — no manual setup needed.
|
|
85
|
-
|
|
86
59
|
Then tweak a few files:
|
|
87
60
|
|
|
88
61
|
- `/domain/entities/user/user.entity.ts` → entity schema
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.4",
|
|
4
4
|
"description": "Next Zod Modules Toolkit",
|
|
5
5
|
"keywords": ["next", "full-stack", "server", "backend", "cli", "scaffolder", "zod", "rest", "contract programming", "react-query", "ddd", "domain-driven"],
|
|
6
6
|
"repository": {
|