@alevnyacow/nzmt 0.15.18 → 0.15.19
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 +8 -3
- package/bin/cli.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ export default async function() {
|
|
|
167
167
|
|
|
168
168
|
## Do I really need to understand DI and other fancy concepts to use NZMT?
|
|
169
169
|
|
|
170
|
-
No. NZMT provides you safe and intuitive facade above `inversifyjs` and automatically registers dependencies. To get an instance you just use `fromDI` function with strongly typed keys like this:
|
|
170
|
+
No. NZMT provides you safe and intuitive facade above `inversifyjs` and automatically registers dependencies. To get an instance you just use `fromDI` function with strongly typed keys in any place of your server code like this:
|
|
171
171
|
|
|
172
172
|
```tsx
|
|
173
173
|
const userService = fromDI<UserService>('UserService')
|
|
@@ -177,6 +177,12 @@ const userService = fromDI<UserService>('UserService')
|
|
|
177
177
|
|
|
178
178
|
Yes — everything is fully editable, including configuration. You can think of NZMT as shadcn-style approach for server-side logic — scaffold, then fully own the code.
|
|
179
179
|
|
|
180
|
+
## Why data layer modules are called `Stores` and not `Repositories`?
|
|
181
|
+
|
|
182
|
+
Good design is impossible without precise terminology. The definition of a "Repository" can vary depending on the terminology used. It’s frustrating when you’ve spent your whole life writing repositories, and then some smart aleck comes along and accuses you of having been writing, say, Data Access Objects all this time! In general, a "Repository" is simply a pattern for working with data. Often, what we really need isn’t a specific pattern, but a properly separated abstraction layer for data handling, which we can then adapt to our needs. That’s exactly why the names of the modules used for the Data Layer in NZMT are kept as abstract as possible, without tying them to any specific data-handling pattern.
|
|
183
|
+
|
|
184
|
+
This approach wasn’t invented here; it has already proven successful, for example, in Go.
|
|
185
|
+
|
|
180
186
|
## Why not just use plain Next.js?
|
|
181
187
|
|
|
182
188
|
You can.
|
|
@@ -199,7 +205,7 @@ Again, you can use whatever you want, God bless you.
|
|
|
199
205
|
`NZMT` sits between `tRPC` and `NestJS`:
|
|
200
206
|
|
|
201
207
|
- from tRPC — type safety and DX
|
|
202
|
-
- from NestJS — structure and layering
|
|
208
|
+
- from NestJS — structure and layering, but more DDD-inspired
|
|
203
209
|
|
|
204
210
|
But:
|
|
205
211
|
- no framework lock-in
|
|
@@ -208,4 +214,3 @@ But:
|
|
|
208
214
|
|
|
209
215
|
Just better Next.js.
|
|
210
216
|
|
|
211
|
-
|
package/bin/cli.js
CHANGED
|
@@ -1080,7 +1080,7 @@ function generateQueries(lowerCase, upperCase) {
|
|
|
1080
1080
|
return acc
|
|
1081
1081
|
}, {})
|
|
1082
1082
|
|
|
1083
|
-
const controllerQueriesPath = path.resolve(projectRoot, `${config.coreFolder}${config.paths.queries}`, `${entityName}-
|
|
1083
|
+
const controllerQueriesPath = path.resolve(projectRoot, `${config.coreFolder}${config.paths.queries}`, `${entityName}-api`, 'queries')
|
|
1084
1084
|
|
|
1085
1085
|
fs.mkdirSync(controllerQueriesPath, { recursive: true })
|
|
1086
1086
|
|
|
@@ -1104,7 +1104,7 @@ function generateQueries(lowerCase, upperCase) {
|
|
|
1104
1104
|
``,
|
|
1105
1105
|
rootMethod === 'GET'
|
|
1106
1106
|
? [
|
|
1107
|
-
`export const use${
|
|
1107
|
+
`export const use${rootMethod} = (payload: Method['payload']) => {`,
|
|
1108
1108
|
`\treturn useQuery<Method['response'], Method['error']>({`,
|
|
1109
1109
|
`\t\tqueryKey: [endpoint, payload],`,
|
|
1110
1110
|
`\t\tqueryFn: () => apiRequest(endpoint, 'GET')(payload)`,
|
|
@@ -1112,7 +1112,7 @@ function generateQueries(lowerCase, upperCase) {
|
|
|
1112
1112
|
`}`
|
|
1113
1113
|
].join('\n')
|
|
1114
1114
|
: [
|
|
1115
|
-
`export const use${
|
|
1115
|
+
`export const use${rootMethod} = () => {`,
|
|
1116
1116
|
`\treturn useMutation<Method['response'], Method['error'], Method['payload']>({`,
|
|
1117
1117
|
`\t\tmutationFn: apiRequest(endpoint, '${rootMethod}')`,
|
|
1118
1118
|
`\t})`,
|