@alevnyacow/nzmt 0.17.4 → 0.18.1
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/bin/cli.js +20 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -110,6 +110,7 @@ function createDefaultConfig() {
|
|
|
110
110
|
infrastructure: '/server/infrastructure',
|
|
111
111
|
entities: '/shared/entities',
|
|
112
112
|
valueObjects: '/shared/value-objects',
|
|
113
|
+
sharedErrors: '/shared/errors',
|
|
113
114
|
queries: '/client/shared/queries',
|
|
114
115
|
clientUtils: '/client/shared/utils'
|
|
115
116
|
},
|
|
@@ -129,6 +130,7 @@ function createDefaultConfig() {
|
|
|
129
130
|
infrastructure: '/server/infrastructure',
|
|
130
131
|
entities: '/shared/entities',
|
|
131
132
|
valueObjects: '/shared/value-objects',
|
|
133
|
+
sharedErrors: '/shared/errors',
|
|
132
134
|
queries: '/client/shared/queries',
|
|
133
135
|
clientUtils: '/client/shared/utils'
|
|
134
136
|
}
|
|
@@ -136,6 +138,20 @@ function createDefaultConfig() {
|
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
|
|
141
|
+
function initSharedErrors() {
|
|
142
|
+
const config = loadConfig()
|
|
143
|
+
const folder = path.resolve(process.cwd(), `${config.coreFolder}${config.paths.sharedErrors}`)
|
|
144
|
+
fs.mkdirSync(folder, { recursive: true })
|
|
145
|
+
|
|
146
|
+
fs.writeFileSync(path.resolve(folder, 'shared-error-codes.ts'), [
|
|
147
|
+
"export enum CommonErrorCodes {",
|
|
148
|
+
"\tNO_DATA_WAS_FOUND = 'COMMON___NO_DATA_WAS_FOUND'",
|
|
149
|
+
"}"
|
|
150
|
+
].join('\n'))
|
|
151
|
+
|
|
152
|
+
fs.writeFileSync(path.resolve(folder, 'index.ts'), "export * from './shared-error-codes'")
|
|
153
|
+
}
|
|
154
|
+
|
|
139
155
|
function initVO() {
|
|
140
156
|
const config = loadConfig()
|
|
141
157
|
const voFolder = path.resolve(process.cwd(), `${config.coreFolder}${config.paths.valueObjects}`)
|
|
@@ -436,6 +452,7 @@ if (command.toLowerCase() === 'init' || command === 'i') {
|
|
|
436
452
|
initDI()
|
|
437
453
|
initClientUtils()
|
|
438
454
|
initVO()
|
|
455
|
+
initSharedErrors()
|
|
439
456
|
initPrisma()
|
|
440
457
|
initLogger()
|
|
441
458
|
|
|
@@ -983,9 +1000,10 @@ function generateController(upperCase, lowerCase, crudService) {
|
|
|
983
1000
|
// Body
|
|
984
1001
|
|
|
985
1002
|
fs.writeFileSync(path.resolve(folder, `${entityName}.controller.ts`), [
|
|
986
|
-
`import { Controller } from '@alevnyacow/nzmt'`,
|
|
987
1003
|
`import { injectable, inject } from 'inversify'`,
|
|
1004
|
+
`import { Controller } from '@alevnyacow/nzmt'`,
|
|
988
1005
|
`import { DITokens } from '@${config?.paths?.di}'`,
|
|
1006
|
+
crudService ? `import { CommonErrorCodes } from '@${config?.paths?.sharedErrors}'` : undefined,
|
|
989
1007
|
`import { ${lowerCase}ControllerMetadata } from './${entityName}.controller.metadata'`,
|
|
990
1008
|
...importInjections,
|
|
991
1009
|
``,
|
|
@@ -1008,7 +1026,7 @@ function generateController(upperCase, lowerCase, crudService) {
|
|
|
1008
1026
|
``,
|
|
1009
1027
|
`\tdetails_GET = this.endpoints('details_GET', async (payload, { endpointError }) => {`,
|
|
1010
1028
|
`\t\tconst details = await this.${crudServiceLowercase}.getDetails(payload)`,
|
|
1011
|
-
`\t\tif (!details) { throw endpointError(
|
|
1029
|
+
`\t\tif (!details) { throw endpointError(CommonErrorCodes.NO_DATA_WAS_FOUND, 404) }`,
|
|
1012
1030
|
`\t\treturn details`,
|
|
1013
1031
|
`\t})`,
|
|
1014
1032
|
``,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
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": {
|