@alevnyacow/nzmt 0.21.3 → 0.21.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.
Files changed (2) hide show
  1. package/bin/cli.js +10 -14
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -403,21 +403,21 @@ function initPrisma() {
403
403
  )
404
404
  }
405
405
 
406
- function initEndpointGuards() {
406
+ function initGuards() {
407
407
  const config = loadConfig()
408
- const endpointGuardsFolder = path.resolve(process.cwd(), `${config.coreFolder}${config?.paths?.infrastructure}`, 'endpoint-guards')
408
+ const endpointGuardsFolder = path.resolve(process.cwd(), `${config.coreFolder}${config?.paths?.infrastructure}`, 'guards')
409
409
  fs.mkdirSync(endpointGuardsFolder, { recursive: true })
410
410
 
411
- fs.writeFileSync(path.resolve(endpointGuardsFolder, 'endpoint-guards.ts'), [
411
+ fs.writeFileSync(path.resolve(endpointGuardsFolder, 'guards.ts'), [
412
412
  `import type { Controller } from '@alevnyacow/nzmt'`,
413
413
  '',
414
- `export class EndpointGuards {`,
414
+ `export class Guards {`,
415
415
  `\tdummyGuard: Controller.Guard = async () => { return undefined }`,
416
416
  `}`
417
417
  ].join('\n'))
418
418
 
419
419
  fs.writeFileSync(path.resolve(endpointGuardsFolder, 'index.ts'), [
420
- `export * from './endpoint-guards'`
420
+ `export * from './guards'`
421
421
  ].join('\n'))
422
422
 
423
423
  // Update DI
@@ -427,13 +427,13 @@ function initEndpointGuards() {
427
427
  insertBeforeLineInFile(
428
428
  diEntriesPath,
429
429
  'type DIEntries =',
430
- `import { EndpointGuards } from '@${config?.paths?.infrastructure}/endpoint-guards'`
430
+ `import { Guards } from '@${config?.paths?.infrastructure}/guards'`
431
431
  )
432
432
 
433
433
  insertAfterLineInFile(
434
434
  diEntriesPath,
435
435
  '// Infrastructure',
436
- `\tEndpointGuards,`,
436
+ `\tGuards,`,
437
437
  )
438
438
 
439
439
  }
@@ -490,7 +490,7 @@ if (command.toLowerCase() === 'init' || command === 'i') {
490
490
  initSharedErrors()
491
491
  initPrisma()
492
492
  initLogger()
493
- initEndpointGuards()
493
+ initGuards()
494
494
 
495
495
  process.exit(0)
496
496
  }
@@ -971,12 +971,8 @@ function generateController(upperCase, lowerCase, crudService) {
971
971
  if (crudService && !injections.includes(crudService)) {
972
972
  injections = injections.concat(crudService)
973
973
  }
974
- if (!injections.includes('Logger')) {
975
- injections = injections.concat('Logger')
976
- }
977
- if (!injections.includes('EndpointGuards')) {
978
- injections = injections.concat('EndpointGuards')
979
- }
974
+
975
+ injections = ['Logger', 'Guards', ...injections.filter(x => x !== 'Logger' && x !== 'Guards')]
980
976
 
981
977
  const crudServiceLowercase = crudService ? crudService.substring(0, 1).toLowerCase() + crudService.substring(1) : undefined
982
978
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alevnyacow/nzmt",
3
- "version": "0.21.3",
3
+ "version": "0.21.4",
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": {