@alevnyacow/nzmt 0.19.1 → 0.20.0
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 +37 -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')
|
|
@@ -938,6 +972,9 @@ function generateController(upperCase, lowerCase, crudService) {
|
|
|
938
972
|
if (!injections.includes('Logger')) {
|
|
939
973
|
injections = injections.concat('Logger')
|
|
940
974
|
}
|
|
975
|
+
if (!injections.includes('EndpointGuards')) {
|
|
976
|
+
injections = injections.concat('EndpointGuards')
|
|
977
|
+
}
|
|
941
978
|
|
|
942
979
|
const crudServiceLowercase = crudService ? crudService.substring(0, 1).toLowerCase() + crudService.substring(1) : undefined
|
|
943
980
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
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": {
|