@alevnyacow/nzmt 0.8.1 → 0.8.3
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 +7 -2
- package/bin/cli.js +6 -4
- 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
|
package/bin/cli.js
CHANGED
|
@@ -277,7 +277,9 @@ function initDI() {
|
|
|
277
277
|
"export const fromDI = <Result>(key: DITokens) => {",
|
|
278
278
|
"\tconst container = getActiveContainer()",
|
|
279
279
|
"\treturn container.get<Result>(key)",
|
|
280
|
-
"}"
|
|
280
|
+
"}",
|
|
281
|
+
"",
|
|
282
|
+
"export { DITokens }"
|
|
281
283
|
].join('\n'))
|
|
282
284
|
};
|
|
283
285
|
|
|
@@ -431,7 +433,7 @@ function generateStores(lowerCase, upperCase, withEntityPreset) {
|
|
|
431
433
|
fs.writeFileSync(path.resolve(folder, `${entityName}.store.prisma.ts`), [
|
|
432
434
|
`import type { Prisma, PrismaClient } from '${prismaPath}'`,
|
|
433
435
|
`import { DITokens } from '${config?.paths?.di?.replace('.', '@')}'`,
|
|
434
|
-
"import { injectable } from 'inversify'",
|
|
436
|
+
"import { injectable, inject } from 'inversify'",
|
|
435
437
|
"import { Store } from '@alevnyacow/nzmt'",
|
|
436
438
|
`import { type ${upperCase}Store, ${lowerCase}StoreMetadata } from './${entityName}.store'`,
|
|
437
439
|
"",
|
|
@@ -769,7 +771,7 @@ function generateService(lowerCase, upperCase) {
|
|
|
769
771
|
// Service body
|
|
770
772
|
|
|
771
773
|
fs.writeFileSync(path.resolve(folder, `${entityName}.service.ts`), [
|
|
772
|
-
"import { injectable } from 'inversify'",
|
|
774
|
+
"import { injectable, inject } from 'inversify'",
|
|
773
775
|
injections.length ? `import { DITokens } from '${config?.paths?.di?.replace('.', '@')}'` : undefined,
|
|
774
776
|
`import { ${lowerCase}ServiceMetadata } from './${entityName}.service.metadata'`,
|
|
775
777
|
"import { Module } from '@alevnyacow/nzmt'",
|
|
@@ -857,7 +859,7 @@ function generateController(upperCase, lowerCase) {
|
|
|
857
859
|
|
|
858
860
|
fs.writeFileSync(path.resolve(folder, `${entityName}.controller.ts`), [
|
|
859
861
|
`import { Controller } from '@alevnyacow/nzmt'`,
|
|
860
|
-
`import { injectable } from 'inversify'`,
|
|
862
|
+
`import { injectable, inject } from 'inversify'`,
|
|
861
863
|
`import { DITokens } from '${config?.paths?.di?.replace('.', '@')}'`,
|
|
862
864
|
`import { ${lowerCase}ControllerMetadata } from './${entityName}.controller.metadata'`,
|
|
863
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.3",
|
|
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
|
}
|