@alevnyacow/nzmt 0.8.2 → 0.8.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 +9 -4
- package/bin/cli.js +3 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -13,11 +13,16 @@ NZMT is an opinionated toolkit with scaffolding for building structured Next.js
|
|
|
13
13
|
- ⚡ **Dependency Injection** powered by Inversify with no setup required.
|
|
14
14
|
- 🚀 Comes with **scaffolding system** to generate and organize application structure via CLI.
|
|
15
15
|
|
|
16
|
-
# Quick start with
|
|
16
|
+
# Quick start (example with Prisma)
|
|
17
|
+
|
|
18
|
+
1. Generate Prisma client.
|
|
19
|
+
2. Install required peer dependencies (`inversify`, `zod`, `reflect-metadata`).
|
|
20
|
+
2. Enable `Experimental decorators` and `Emit Decorator Metadata` options in your tsconfig.json.
|
|
21
|
+
3. Run the following:
|
|
17
22
|
|
|
18
23
|
```bash
|
|
19
24
|
# scaffolder initialization with Prisma (must be done once)
|
|
20
|
-
npx nzmt init prismaClientPath
|
|
25
|
+
npx nzmt init prismaClientPath:./app/generated/prisma/client
|
|
21
26
|
|
|
22
27
|
# product entity with title and price fields
|
|
23
28
|
npx nzmt entity product f:title-string,price-int.positive
|
|
@@ -25,10 +30,10 @@ npx nzmt entity product f:title-string,price-int.positive
|
|
|
25
30
|
# product store (with Prisma implementation, RAM implementation and DI)
|
|
26
31
|
npx nzmt store product
|
|
27
32
|
|
|
28
|
-
# product service with injected product store
|
|
33
|
+
# product service with injected product store (with configured DI)
|
|
29
34
|
npx nzmt service product i:ProductStore
|
|
30
35
|
|
|
31
|
-
# shop controller with injected shop service and logger
|
|
36
|
+
# shop controller with injected shop service and logger (with configured DI)
|
|
32
37
|
npx nzmt controller shop i:Logger,ProductService
|
|
33
38
|
```
|
|
34
39
|
|
package/bin/cli.js
CHANGED
|
@@ -433,7 +433,7 @@ function generateStores(lowerCase, upperCase, withEntityPreset) {
|
|
|
433
433
|
fs.writeFileSync(path.resolve(folder, `${entityName}.store.prisma.ts`), [
|
|
434
434
|
`import type { Prisma, PrismaClient } from '${prismaPath}'`,
|
|
435
435
|
`import { DITokens } from '${config?.paths?.di?.replace('.', '@')}'`,
|
|
436
|
-
"import { injectable } from 'inversify'",
|
|
436
|
+
"import { injectable, inject } from 'inversify'",
|
|
437
437
|
"import { Store } from '@alevnyacow/nzmt'",
|
|
438
438
|
`import { type ${upperCase}Store, ${lowerCase}StoreMetadata } from './${entityName}.store'`,
|
|
439
439
|
"",
|
|
@@ -771,7 +771,7 @@ function generateService(lowerCase, upperCase) {
|
|
|
771
771
|
// Service body
|
|
772
772
|
|
|
773
773
|
fs.writeFileSync(path.resolve(folder, `${entityName}.service.ts`), [
|
|
774
|
-
"import { injectable } from 'inversify'",
|
|
774
|
+
"import { injectable, inject } from 'inversify'",
|
|
775
775
|
injections.length ? `import { DITokens } from '${config?.paths?.di?.replace('.', '@')}'` : undefined,
|
|
776
776
|
`import { ${lowerCase}ServiceMetadata } from './${entityName}.service.metadata'`,
|
|
777
777
|
"import { Module } from '@alevnyacow/nzmt'",
|
|
@@ -859,7 +859,7 @@ function generateController(upperCase, lowerCase) {
|
|
|
859
859
|
|
|
860
860
|
fs.writeFileSync(path.resolve(folder, `${entityName}.controller.ts`), [
|
|
861
861
|
`import { Controller } from '@alevnyacow/nzmt'`,
|
|
862
|
-
`import { injectable } from 'inversify'`,
|
|
862
|
+
`import { injectable, inject } from 'inversify'`,
|
|
863
863
|
`import { DITokens } from '${config?.paths?.di?.replace('.', '@')}'`,
|
|
864
864
|
`import { ${lowerCase}ControllerMetadata } from './${entityName}.controller.metadata'`,
|
|
865
865
|
...importInjections,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "Next Zod Modules Toolkit",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"next": ">=13 <17",
|
|
46
46
|
"zod": ">=4 <5",
|
|
47
|
-
"inversify": ">=7 <9"
|
|
47
|
+
"inversify": ">=7 <9",
|
|
48
|
+
"reflect-metadata": "^0.2.2"
|
|
48
49
|
},
|
|
49
50
|
"private": false
|
|
50
51
|
}
|