@alevnyacow/nzmt 0.19.1 → 0.20.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 +38 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -403,6 +403,40 @@ function initPrisma() {
|
|
|
403
403
|
)
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
+
function initAPIGuards() {
|
|
407
|
+
const config = loadConfig()
|
|
408
|
+
const endpointGuardsFolder = path.resolve(process.cwd(), `${config.coreFolder}${config?.paths?.infrastructure}`, 'endpoint-guards')
|
|
409
|
+
fs.mkdirSync(endpointGuardsFolder, { recursive: true })
|
|
410
|
+
|
|
411
|
+
fs.writeFileSync(path.resolve(endpointGuardsFolder, 'endpoint-guards.ts'), [
|
|
412
|
+
`import { Controller } from '@alevnyacow/nzmt'`,
|
|
413
|
+
`export class EndpointGuards {`,
|
|
414
|
+
`\tdummyGuard: Controller.Guard = async () => { return undefined }`,
|
|
415
|
+
`}`
|
|
416
|
+
].join('\n'))
|
|
417
|
+
|
|
418
|
+
fs.writeFileSync(path.resolve(endpointGuardsFolder, 'index.ts'), [
|
|
419
|
+
`export * from './endpoint-guards'`
|
|
420
|
+
].join('\n'))
|
|
421
|
+
|
|
422
|
+
// Update DI
|
|
423
|
+
|
|
424
|
+
const diEntriesPath = path.resolve(process.cwd(), `${config.coreFolder}${config?.paths?.di}`, 'entries.di.ts')
|
|
425
|
+
|
|
426
|
+
insertBeforeLineInFile(
|
|
427
|
+
diEntriesPath,
|
|
428
|
+
'type DIEntries =',
|
|
429
|
+
`import { EndpointGuards } from '@${config?.paths?.infrastructure}/endpoint-guards'`
|
|
430
|
+
)
|
|
431
|
+
|
|
432
|
+
insertAfterLineInFile(
|
|
433
|
+
diEntriesPath,
|
|
434
|
+
'// Infrastructure',
|
|
435
|
+
`\tEndpointGuards,`,
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
}
|
|
439
|
+
|
|
406
440
|
function initLogger() {
|
|
407
441
|
const config = loadConfig()
|
|
408
442
|
const loggerFolder = path.resolve(process.cwd(), `${config.coreFolder}${config?.paths?.infrastructure}`, 'logger')
|
|
@@ -455,6 +489,7 @@ if (command.toLowerCase() === 'init' || command === 'i') {
|
|
|
455
489
|
initSharedErrors()
|
|
456
490
|
initPrisma()
|
|
457
491
|
initLogger()
|
|
492
|
+
initAPIGuards()
|
|
458
493
|
|
|
459
494
|
process.exit(0)
|
|
460
495
|
}
|
|
@@ -938,6 +973,9 @@ function generateController(upperCase, lowerCase, crudService) {
|
|
|
938
973
|
if (!injections.includes('Logger')) {
|
|
939
974
|
injections = injections.concat('Logger')
|
|
940
975
|
}
|
|
976
|
+
if (!injections.includes('EndpointGuards')) {
|
|
977
|
+
injections = injections.concat('EndpointGuards')
|
|
978
|
+
}
|
|
941
979
|
|
|
942
980
|
const crudServiceLowercase = crudService ? crudService.substring(0, 1).toLowerCase() + crudService.substring(1) : undefined
|
|
943
981
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.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": {
|