@alevnyacow/nzmt 0.15.6 → 0.15.8
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 +6 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ npm i inversify zod reflect-metadata @alevnyacow/nzmt
|
|
|
33
33
|
|
|
34
34
|
# 3. Initialize NZMT (once)
|
|
35
35
|
npx nzmt init prismaClientPath:@/app/generated/prisma/client
|
|
36
|
+
# it scaffolded `nzmt.config.json`, infrastructure, client utils, etc.
|
|
36
37
|
|
|
37
38
|
# 4. Scaffold CRUD API for `User` entity
|
|
38
39
|
npx nzmt crud-api user
|
|
@@ -100,9 +101,7 @@ export const userStoreMetadata = {
|
|
|
100
101
|
name: 'UserStore'
|
|
101
102
|
} satisfies Store.Metadata
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
export type UserStore = Store.Contract<typeof userStoreMetadata>
|
|
104
|
+
...scaffolded code
|
|
106
105
|
```
|
|
107
106
|
|
|
108
107
|
Contracts are pretty self-explainatory, but let's break this down anyway.
|
|
@@ -129,13 +128,7 @@ Second file is a `Prisma` implementation:
|
|
|
129
128
|
```ts
|
|
130
129
|
/** /server/stores/users/user.store.prisma */
|
|
131
130
|
|
|
132
|
-
|
|
133
|
-
import { DITokens } from '@/server/di'
|
|
134
|
-
import { injectable, inject } from 'inversify'
|
|
135
|
-
import { Store } from '@alevnyacow/nzmt'
|
|
136
|
-
import { type UserStore, userStoreMetadata } from './user.store'
|
|
137
|
-
|
|
138
|
-
type Types = Store.Types<UserStore>
|
|
131
|
+
...scaffolded code
|
|
139
132
|
|
|
140
133
|
const mappers = {
|
|
141
134
|
toFindOnePayload: (source: Types['findOnePayload']): Prisma.UserWhereUniqueInput => {
|
|
@@ -172,7 +165,7 @@ const mappers = {
|
|
|
172
165
|
|
|
173
166
|
@injectable()
|
|
174
167
|
export class UserPrismaStore implements UserStore {
|
|
175
|
-
..scaffolded
|
|
168
|
+
..scaffolded code
|
|
176
169
|
```
|
|
177
170
|
|
|
178
171
|
Pretty cool, right? All you need to do is implementing `mappers` and in the vast majority of cases it's enough to have working `Prisma` store. And even more - `RAM` implementation works out of the box! ✨
|
|
@@ -185,13 +178,11 @@ Works out of the box. ✨
|
|
|
185
178
|
|
|
186
179
|
Works out of the box. ✨
|
|
187
180
|
|
|
188
|
-
### 5. Scaffolded
|
|
189
|
-
|
|
190
|
-
### 6. Scaffolded `Route handlers` in `/app/api`
|
|
181
|
+
### 5. Scaffolded `Route handlers` in `/app/api`
|
|
191
182
|
|
|
192
183
|
Works out of the box. ✨
|
|
193
184
|
|
|
194
|
-
###
|
|
185
|
+
### 6. Scaffolded `React queries` for all controller methods
|
|
195
186
|
|
|
196
187
|
Also works out of the box! ✨
|
|
197
188
|
|