@devbro/pashmak 0.1.42 → 0.1.44

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 (52) hide show
  1. package/dist/app/console/generate/GenerateApiDocsCommand.d.mts +4 -1
  2. package/dist/app/console/generate/GenerateApiDocsCommand.mjs +56 -4
  3. package/dist/app/console/generate/GenerateApiDocsCommand.mjs.map +1 -1
  4. package/dist/app/console/project/CreateProjectCommand.mjs +27 -2
  5. package/dist/app/console/project/CreateProjectCommand.mjs.map +1 -1
  6. package/dist/app/console/project/base_project/package.json.tpl +7 -2
  7. package/dist/app/console/project/base_project/src/app/queues/index.ts.tpl +9 -0
  8. package/dist/app/console/project/base_project/src/config/caches.ts.tpl +2 -4
  9. package/dist/app/console/project/base_project/src/config/databases.ts.tpl +7 -9
  10. package/dist/app/console/project/base_project/src/config/default.mts.tpl +17 -3
  11. package/dist/app/console/project/base_project/src/config/loggers.ts.tpl +6 -8
  12. package/dist/app/console/project/base_project/src/config/mailer.ts.tpl +15 -16
  13. package/dist/app/console/project/base_project/src/config/queues.ts.tpl +2 -4
  14. package/dist/app/console/project/base_project/src/config/storages.ts.tpl +5 -4
  15. package/dist/app/console/project/base_project/src/helpers/QueryKit.ts.tpl +175 -0
  16. package/dist/app/console/project/base_project/src/helpers/index.ts.tpl +96 -0
  17. package/dist/app/console/project/base_project/src/helpers/validation.ts.tpl +26 -0
  18. package/dist/app/console/project/base_project/src/initialize.ts.tpl +64 -7
  19. package/dist/app/console/project/base_project/src/middlewares.ts.tpl +1 -1
  20. package/dist/bin/app/console/DefaultCommand.cjs +0 -19
  21. package/dist/bin/app/console/KeyGenerateCommand.cjs +0 -19
  22. package/dist/bin/app/console/StartCommand.cjs +0 -19
  23. package/dist/bin/app/console/generate/GenerateApiDocsCommand.cjs +62 -24
  24. package/dist/bin/app/console/generate/GenerateControllerCommand.cjs +0 -19
  25. package/dist/bin/app/console/generate/index.cjs +62 -24
  26. package/dist/bin/app/console/index.cjs +89 -26
  27. package/dist/bin/app/console/migrate/GenerateMigrateCommand.cjs +0 -19
  28. package/dist/bin/app/console/migrate/MigrateCommand.cjs +0 -19
  29. package/dist/bin/app/console/migrate/MigrateRollbackCommand.cjs +0 -19
  30. package/dist/bin/app/console/migrate/index.cjs +0 -19
  31. package/dist/bin/app/console/project/CreateProjectCommand.cjs +27 -2
  32. package/dist/bin/app/console/queue/GenerateQueueMigrateCommand.cjs +0 -19
  33. package/dist/bin/bin/pashmak_cli.cjs +27 -2
  34. package/dist/bin/cache.cjs +0 -19
  35. package/dist/bin/facades.cjs +0 -19
  36. package/dist/bin/factories.cjs +0 -19
  37. package/dist/bin/index.cjs +96 -29
  38. package/dist/bin/middlewares.cjs +0 -19
  39. package/dist/bin/queue.cjs +0 -19
  40. package/dist/bin/router.cjs +0 -9
  41. package/dist/bin/storage.cjs +24 -0
  42. package/dist/config.d.mts +1 -0
  43. package/dist/facades.mjs +0 -19
  44. package/dist/facades.mjs.map +1 -1
  45. package/dist/router.d.mts +1 -3
  46. package/dist/router.mjs +1 -9
  47. package/dist/router.mjs.map +1 -1
  48. package/dist/storage.d.mts +1 -0
  49. package/dist/storage.mjs +2 -0
  50. package/dist/storage.mjs.map +1 -0
  51. package/package.json +17 -11
  52. package/dist/app/console/project/base_project/src/helpers.ts.tpl +0 -28
@@ -1636,7 +1636,6 @@ var http_exports = {};
1636
1636
  __reExport(http_exports, require("@devbro/neko-http"));
1637
1637
 
1638
1638
  // src/facades.mts
1639
- var yup = __toESM(require("yup"), 1);
1640
1639
  var import_neko_logger = require("@devbro/neko-logger");
1641
1640
 
1642
1641
  // src/factories.mts
@@ -1708,8 +1707,8 @@ var DatabaseTransport = class {
1708
1707
  }
1709
1708
  });
1710
1709
  }, "processMessage");
1711
- constructor(config9 = {}) {
1712
- this.config = { ...this.config, ...config9 };
1710
+ constructor(config10 = {}) {
1711
+ this.config = { ...this.config, ...config10 };
1713
1712
  this.repeater = (0, import_neko_helper.createRepeater)(
1714
1713
  this.processMessage,
1715
1714
  this.config.listen_interval * 1e3
@@ -1849,24 +1848,6 @@ var httpServer = (0, import_neko_helper2.createSingleton)(() => {
1849
1848
  res.end(JSON.stringify({ message: err.message, error: err.code }));
1850
1849
  logger().warn({ msg: "HttpError: " + err.message, err });
1851
1850
  return;
1852
- } else if (err instanceof yup.ValidationError) {
1853
- res.writeHead(422, { "Content-Type": "application/json" });
1854
- const errs = {};
1855
- err.inner.forEach((e) => {
1856
- const sanitizedParams = { ...e.params };
1857
- if (/passw/i.test(e.path)) {
1858
- sanitizedParams.value = "******";
1859
- sanitizedParams.originalValue = "******";
1860
- }
1861
- errs[e.path] = {
1862
- type: e.type,
1863
- message: e.message,
1864
- params: sanitizedParams
1865
- };
1866
- });
1867
- res.end(JSON.stringify({ message: "validation error", errors: errs }));
1868
- logger().warn({ msg: "ValidationError: " + err.message, err });
1869
- return;
1870
1851
  } else {
1871
1852
  logger().error({ msg: "Error: " + err.message, err });
1872
1853
  }
@@ -2338,6 +2319,13 @@ cli().register(GenerateControllerCommand);
2338
2319
  var import_clipanion9 = require("clipanion");
2339
2320
  var import_path7 = __toESM(require("path"), 1);
2340
2321
  var fs6 = __toESM(require("fs/promises"), 1);
2322
+
2323
+ // src/config.mts
2324
+ var config_exports = {};
2325
+ __reExport(config_exports, require("@devbro/neko-config"));
2326
+
2327
+ // src/app/console/generate/GenerateApiDocsCommand.mts
2328
+ var import_neko_helper3 = require("@devbro/neko-helper");
2341
2329
  var GenerateApiDocsCommand = class extends import_clipanion9.Command {
2342
2330
  static {
2343
2331
  __name(this, "GenerateApiDocsCommand");
@@ -2346,7 +2334,44 @@ var GenerateApiDocsCommand = class extends import_clipanion9.Command {
2346
2334
  [`make`, `apidocs`],
2347
2335
  [`generate`, `apidocs`]
2348
2336
  ];
2337
+ static usage = import_clipanion9.Command.Usage({
2338
+ category: `Generate`,
2339
+ description: `Generate OpenAPI documentation from routes`,
2340
+ details: `
2341
+ This command generates OpenAPI 3.0 specification documentation by analyzing
2342
+ your application's routes and merging with example files.
2343
+
2344
+ The generated documentation includes:
2345
+ - All registered routes with their HTTP methods
2346
+ - Path parameters extracted from route definitions
2347
+ - Request body schemas for POST, PUT, and PATCH methods
2348
+ - Response schemas
2349
+
2350
+ The command will merge files specified in config.api_docs.merge_files
2351
+ and output the final documentation to config.api_docs.output.
2352
+
2353
+ This command depends on config data. make sure your default config contains the following:
2354
+ api_docs: {
2355
+ merge_files: [
2356
+ path.join(__dirname, '../..', 'private', 'openapi_examples.json'),
2357
+ path.join(__dirname, '../..', 'private', 'openapi_base.json'),
2358
+ path.join(__dirname, '../..', 'private', 'openapi_user_changes.json'),
2359
+ ],
2360
+ output: path.join(__dirname, '../..', 'private', 'openapi.json'),
2361
+ }
2362
+ `,
2363
+ examples: [[`Generate API documentation`, `$0 generate apidocs`]]
2364
+ });
2365
+ help = import_clipanion9.Option.Boolean(`--help,-h`, false, {
2366
+ description: `Show help message for this command`
2367
+ });
2349
2368
  async execute() {
2369
+ if (this.help) {
2370
+ this.context.stdout.write(
2371
+ this.constructor.usage?.toString() || "No help available\n"
2372
+ );
2373
+ return 0;
2374
+ }
2350
2375
  const rootDir = process.cwd();
2351
2376
  this.context.stdout.write(`Generating OpenAPI documentation...
2352
2377
  `);
@@ -2411,9 +2436,8 @@ var GenerateApiDocsCommand = class extends import_clipanion9.Command {
2411
2436
  }
2412
2437
  }
2413
2438
  }
2414
- const publicDir = import_path7.default.join(rootDir, "public");
2415
- await fs6.mkdir(publicDir, { recursive: true });
2416
- const outputPath = import_path7.default.join(publicDir, "openapi.json");
2439
+ await fs6.mkdir(config_exports.config.get("private_path"), { recursive: true });
2440
+ const outputPath = import_path7.default.join(config_exports.config.get("private_path"), "openapi.json");
2417
2441
  await fs6.writeFile(
2418
2442
  outputPath,
2419
2443
  JSON.stringify(openApiSpec, null, 2),
@@ -2425,6 +2449,20 @@ var GenerateApiDocsCommand = class extends import_clipanion9.Command {
2425
2449
  );
2426
2450
  this.context.stdout.write(`Total routes documented: ${routes.length}
2427
2451
  `);
2452
+ let files_to_merge = config_exports.config.get("api_docs.merge_files");
2453
+ let final_api_docs = {};
2454
+ for (let file_path of files_to_merge) {
2455
+ let file_json = JSON.parse(await fs6.readFile(file_path, "utf8"));
2456
+ import_neko_helper3.Arr.deepMerge(final_api_docs, file_json);
2457
+ }
2458
+ await fs6.writeFile(
2459
+ config_exports.config.get("api_docs.output"),
2460
+ JSON.stringify(final_api_docs, null, 2)
2461
+ );
2462
+ this.context.stdout.write(
2463
+ `wrote final open api document to : ${config_exports.config.get("api_docs.output")}
2464
+ `
2465
+ );
2428
2466
  }
2429
2467
  extractParameters(routePath) {
2430
2468
  const paramRegex = /:([a-zA-Z0-9_]+)/g;
@@ -2454,6 +2492,7 @@ var fs7 = __toESM(require("fs/promises"), 1);
2454
2492
  var import_url3 = require("url");
2455
2493
  var import_handlebars3 = __toESM(require("handlebars"), 1);
2456
2494
  var import_child_process = require("child_process");
2495
+ var import_prompts = require("@inquirer/prompts");
2457
2496
  var import_meta3 = {};
2458
2497
  var CreateProjectCommand = class extends import_clipanion10.Command {
2459
2498
  static {
@@ -2501,6 +2540,27 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
2501
2540
  return 1;
2502
2541
  } catch {
2503
2542
  }
2543
+ const validation_library = await (0, import_prompts.select)({
2544
+ message: "Select a package you want for validation",
2545
+ choices: [
2546
+ {
2547
+ name: "Yup",
2548
+ value: "yup",
2549
+ description: "https://github.com/jquense/yup"
2550
+ },
2551
+ {
2552
+ name: "Zod",
2553
+ value: "zod",
2554
+ description: "https://zod.dev/"
2555
+ },
2556
+ new import_prompts.Separator(),
2557
+ {
2558
+ name: "None",
2559
+ value: "none",
2560
+ disabled: false
2561
+ }
2562
+ ]
2563
+ });
2504
2564
  await fs7.mkdir(projectPath, { recursive: true });
2505
2565
  console.log(`Created project directory at: ${projectPath}`);
2506
2566
  const dirname = typeof __dirname === "undefined" ? import_path8.default.dirname((0, import_url3.fileURLToPath)(import_meta3.url)) : __dirname;
@@ -2510,7 +2570,9 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
2510
2570
  }
2511
2571
  console.log(`Using base project path: ${basePath}`);
2512
2572
  const baseProjectPath = basePath;
2513
- await this.processTplFolder(baseProjectPath, projectPath, {});
2573
+ await this.processTplFolder(baseProjectPath, projectPath, {
2574
+ validation_library
2575
+ });
2514
2576
  console.log(`Copied base project files to: ${projectPath}`);
2515
2577
  const packageJsonPath = import_path8.default.join(projectPath, `package.json`);
2516
2578
  const packageJson = JSON.parse(await fs7.readFile(packageJsonPath, `utf-8`));
@@ -2540,7 +2602,7 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
2540
2602
  await fs7.mkdir(destPath, { recursive: true });
2541
2603
  await this.processTplFolder(srcPath, destPath, data);
2542
2604
  } else if (file.name.endsWith(".tpl")) {
2543
- await this.processTplFile(srcPath, destPath, {});
2605
+ await this.processTplFile(srcPath, destPath, data);
2544
2606
  } else {
2545
2607
  throw new Error(
2546
2608
  "unexpected non tpl file: " + srcPath + " " + file.name
@@ -2549,6 +2611,7 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
2549
2611
  }
2550
2612
  }
2551
2613
  async processTplFile(src, dest, data = {}) {
2614
+ import_handlebars3.default.registerHelper("eq", (a, b) => a === b);
2552
2615
  const compiledTemplate = import_handlebars3.default.compile(
2553
2616
  (await fs7.readFile(src)).toString()
2554
2617
  );
@@ -472,7 +472,6 @@ var http_exports = {};
472
472
  __reExport(http_exports, require("@devbro/neko-http"));
473
473
 
474
474
  // src/facades.mts
475
- var yup = __toESM(require("yup"), 1);
476
475
  var import_neko_logger = require("@devbro/neko-logger");
477
476
 
478
477
  // src/factories.mts
@@ -685,24 +684,6 @@ var httpServer = (0, import_neko_helper2.createSingleton)(() => {
685
684
  res.end(JSON.stringify({ message: err.message, error: err.code }));
686
685
  logger().warn({ msg: "HttpError: " + err.message, err });
687
686
  return;
688
- } else if (err instanceof yup.ValidationError) {
689
- res.writeHead(422, { "Content-Type": "application/json" });
690
- const errs = {};
691
- err.inner.forEach((e) => {
692
- const sanitizedParams = { ...e.params };
693
- if (/passw/i.test(e.path)) {
694
- sanitizedParams.value = "******";
695
- sanitizedParams.originalValue = "******";
696
- }
697
- errs[e.path] = {
698
- type: e.type,
699
- message: e.message,
700
- params: sanitizedParams
701
- };
702
- });
703
- res.end(JSON.stringify({ message: "validation error", errors: errs }));
704
- logger().warn({ msg: "ValidationError: " + err.message, err });
705
- return;
706
687
  } else {
707
688
  logger().error({ msg: "Error: " + err.message, err });
708
689
  }
@@ -472,7 +472,6 @@ var http_exports = {};
472
472
  __reExport(http_exports, require("@devbro/neko-http"));
473
473
 
474
474
  // src/facades.mts
475
- var yup = __toESM(require("yup"), 1);
476
475
  var import_neko_logger = require("@devbro/neko-logger");
477
476
 
478
477
  // src/factories.mts
@@ -685,24 +684,6 @@ var httpServer = (0, import_neko_helper2.createSingleton)(() => {
685
684
  res.end(JSON.stringify({ message: err.message, error: err.code }));
686
685
  logger().warn({ msg: "HttpError: " + err.message, err });
687
686
  return;
688
- } else if (err instanceof yup.ValidationError) {
689
- res.writeHead(422, { "Content-Type": "application/json" });
690
- const errs = {};
691
- err.inner.forEach((e) => {
692
- const sanitizedParams = { ...e.params };
693
- if (/passw/i.test(e.path)) {
694
- sanitizedParams.value = "******";
695
- sanitizedParams.originalValue = "******";
696
- }
697
- errs[e.path] = {
698
- type: e.type,
699
- message: e.message,
700
- params: sanitizedParams
701
- };
702
- });
703
- res.end(JSON.stringify({ message: "validation error", errors: errs }));
704
- logger().warn({ msg: "ValidationError: " + err.message, err });
705
- return;
706
687
  } else {
707
688
  logger().error({ msg: "Error: " + err.message, err });
708
689
  }
@@ -1627,7 +1627,6 @@ var http_exports = {};
1627
1627
  __reExport(http_exports, require("@devbro/neko-http"));
1628
1628
 
1629
1629
  // src/facades.mts
1630
- var yup = __toESM(require("yup"), 1);
1631
1630
  var import_neko_logger = require("@devbro/neko-logger");
1632
1631
 
1633
1632
  // src/factories.mts
@@ -1840,24 +1839,6 @@ var httpServer = (0, import_neko_helper2.createSingleton)(() => {
1840
1839
  res.end(JSON.stringify({ message: err.message, error: err.code }));
1841
1840
  logger().warn({ msg: "HttpError: " + err.message, err });
1842
1841
  return;
1843
- } else if (err instanceof yup.ValidationError) {
1844
- res.writeHead(422, { "Content-Type": "application/json" });
1845
- const errs = {};
1846
- err.inner.forEach((e) => {
1847
- const sanitizedParams = { ...e.params };
1848
- if (/passw/i.test(e.path)) {
1849
- sanitizedParams.value = "******";
1850
- sanitizedParams.originalValue = "******";
1851
- }
1852
- errs[e.path] = {
1853
- type: e.type,
1854
- message: e.message,
1855
- params: sanitizedParams
1856
- };
1857
- });
1858
- res.end(JSON.stringify({ message: "validation error", errors: errs }));
1859
- logger().warn({ msg: "ValidationError: " + err.message, err });
1860
- return;
1861
1842
  } else {
1862
1843
  logger().error({ msg: "Error: " + err.message, err });
1863
1844
  }
@@ -1629,7 +1629,6 @@ var http_exports = {};
1629
1629
  __reExport(http_exports, require("@devbro/neko-http"));
1630
1630
 
1631
1631
  // src/facades.mts
1632
- var yup = __toESM(require("yup"), 1);
1633
1632
  var import_neko_logger = require("@devbro/neko-logger");
1634
1633
 
1635
1634
  // src/factories.mts
@@ -1842,24 +1841,6 @@ var httpServer = (0, import_neko_helper2.createSingleton)(() => {
1842
1841
  res.end(JSON.stringify({ message: err.message, error: err.code }));
1843
1842
  logger().warn({ msg: "HttpError: " + err.message, err });
1844
1843
  return;
1845
- } else if (err instanceof yup.ValidationError) {
1846
- res.writeHead(422, { "Content-Type": "application/json" });
1847
- const errs = {};
1848
- err.inner.forEach((e) => {
1849
- const sanitizedParams = { ...e.params };
1850
- if (/passw/i.test(e.path)) {
1851
- sanitizedParams.value = "******";
1852
- sanitizedParams.originalValue = "******";
1853
- }
1854
- errs[e.path] = {
1855
- type: e.type,
1856
- message: e.message,
1857
- params: sanitizedParams
1858
- };
1859
- });
1860
- res.end(JSON.stringify({ message: "validation error", errors: errs }));
1861
- logger().warn({ msg: "ValidationError: " + err.message, err });
1862
- return;
1863
1844
  } else {
1864
1845
  logger().error({ msg: "Error: " + err.message, err });
1865
1846
  }
@@ -41,6 +41,7 @@ var fs = __toESM(require("fs/promises"), 1);
41
41
  var import_url = require("url");
42
42
  var import_handlebars = __toESM(require("handlebars"), 1);
43
43
  var import_child_process = require("child_process");
44
+ var import_prompts = require("@inquirer/prompts");
44
45
  var import_meta = {};
45
46
  var CreateProjectCommand = class extends import_clipanion.Command {
46
47
  static {
@@ -88,6 +89,27 @@ var CreateProjectCommand = class extends import_clipanion.Command {
88
89
  return 1;
89
90
  } catch {
90
91
  }
92
+ const validation_library = await (0, import_prompts.select)({
93
+ message: "Select a package you want for validation",
94
+ choices: [
95
+ {
96
+ name: "Yup",
97
+ value: "yup",
98
+ description: "https://github.com/jquense/yup"
99
+ },
100
+ {
101
+ name: "Zod",
102
+ value: "zod",
103
+ description: "https://zod.dev/"
104
+ },
105
+ new import_prompts.Separator(),
106
+ {
107
+ name: "None",
108
+ value: "none",
109
+ disabled: false
110
+ }
111
+ ]
112
+ });
91
113
  await fs.mkdir(projectPath, { recursive: true });
92
114
  console.log(`Created project directory at: ${projectPath}`);
93
115
  const dirname = typeof __dirname === "undefined" ? import_path.default.dirname((0, import_url.fileURLToPath)(import_meta.url)) : __dirname;
@@ -97,7 +119,9 @@ var CreateProjectCommand = class extends import_clipanion.Command {
97
119
  }
98
120
  console.log(`Using base project path: ${basePath}`);
99
121
  const baseProjectPath = basePath;
100
- await this.processTplFolder(baseProjectPath, projectPath, {});
122
+ await this.processTplFolder(baseProjectPath, projectPath, {
123
+ validation_library
124
+ });
101
125
  console.log(`Copied base project files to: ${projectPath}`);
102
126
  const packageJsonPath = import_path.default.join(projectPath, `package.json`);
103
127
  const packageJson = JSON.parse(await fs.readFile(packageJsonPath, `utf-8`));
@@ -127,7 +151,7 @@ var CreateProjectCommand = class extends import_clipanion.Command {
127
151
  await fs.mkdir(destPath, { recursive: true });
128
152
  await this.processTplFolder(srcPath, destPath, data);
129
153
  } else if (file.name.endsWith(".tpl")) {
130
- await this.processTplFile(srcPath, destPath, {});
154
+ await this.processTplFile(srcPath, destPath, data);
131
155
  } else {
132
156
  throw new Error(
133
157
  "unexpected non tpl file: " + srcPath + " " + file.name
@@ -136,6 +160,7 @@ var CreateProjectCommand = class extends import_clipanion.Command {
136
160
  }
137
161
  }
138
162
  async processTplFile(src, dest, data = {}) {
163
+ import_handlebars.default.registerHelper("eq", (a, b) => a === b);
139
164
  const compiledTemplate = import_handlebars.default.compile(
140
165
  (await fs.readFile(src)).toString()
141
166
  );
@@ -472,7 +472,6 @@ var http_exports = {};
472
472
  __reExport(http_exports, require("@devbro/neko-http"));
473
473
 
474
474
  // src/facades.mts
475
- var yup = __toESM(require("yup"), 1);
476
475
  var import_neko_logger = require("@devbro/neko-logger");
477
476
 
478
477
  // src/factories.mts
@@ -685,24 +684,6 @@ var httpServer = (0, import_neko_helper2.createSingleton)(() => {
685
684
  res.end(JSON.stringify({ message: err.message, error: err.code }));
686
685
  logger().warn({ msg: "HttpError: " + err.message, err });
687
686
  return;
688
- } else if (err instanceof yup.ValidationError) {
689
- res.writeHead(422, { "Content-Type": "application/json" });
690
- const errs = {};
691
- err.inner.forEach((e) => {
692
- const sanitizedParams = { ...e.params };
693
- if (/passw/i.test(e.path)) {
694
- sanitizedParams.value = "******";
695
- sanitizedParams.originalValue = "******";
696
- }
697
- errs[e.path] = {
698
- type: e.type,
699
- message: e.message,
700
- params: sanitizedParams
701
- };
702
- });
703
- res.end(JSON.stringify({ message: "validation error", errors: errs }));
704
- logger().warn({ msg: "ValidationError: " + err.message, err });
705
- return;
706
687
  } else {
707
688
  logger().error({ msg: "Error: " + err.message, err });
708
689
  }
@@ -35,6 +35,7 @@ var fs = __toESM(require("fs/promises"), 1);
35
35
  var import_url = require("url");
36
36
  var import_handlebars = __toESM(require("handlebars"), 1);
37
37
  var import_child_process = require("child_process");
38
+ var import_prompts = require("@inquirer/prompts");
38
39
  var import_meta = {};
39
40
  var CreateProjectCommand = class extends import_clipanion.Command {
40
41
  static {
@@ -82,6 +83,27 @@ var CreateProjectCommand = class extends import_clipanion.Command {
82
83
  return 1;
83
84
  } catch {
84
85
  }
86
+ const validation_library = await (0, import_prompts.select)({
87
+ message: "Select a package you want for validation",
88
+ choices: [
89
+ {
90
+ name: "Yup",
91
+ value: "yup",
92
+ description: "https://github.com/jquense/yup"
93
+ },
94
+ {
95
+ name: "Zod",
96
+ value: "zod",
97
+ description: "https://zod.dev/"
98
+ },
99
+ new import_prompts.Separator(),
100
+ {
101
+ name: "None",
102
+ value: "none",
103
+ disabled: false
104
+ }
105
+ ]
106
+ });
85
107
  await fs.mkdir(projectPath, { recursive: true });
86
108
  console.log(`Created project directory at: ${projectPath}`);
87
109
  const dirname = typeof __dirname === "undefined" ? import_path.default.dirname((0, import_url.fileURLToPath)(import_meta.url)) : __dirname;
@@ -91,7 +113,9 @@ var CreateProjectCommand = class extends import_clipanion.Command {
91
113
  }
92
114
  console.log(`Using base project path: ${basePath}`);
93
115
  const baseProjectPath = basePath;
94
- await this.processTplFolder(baseProjectPath, projectPath, {});
116
+ await this.processTplFolder(baseProjectPath, projectPath, {
117
+ validation_library
118
+ });
95
119
  console.log(`Copied base project files to: ${projectPath}`);
96
120
  const packageJsonPath = import_path.default.join(projectPath, `package.json`);
97
121
  const packageJson = JSON.parse(await fs.readFile(packageJsonPath, `utf-8`));
@@ -121,7 +145,7 @@ var CreateProjectCommand = class extends import_clipanion.Command {
121
145
  await fs.mkdir(destPath, { recursive: true });
122
146
  await this.processTplFolder(srcPath, destPath, data);
123
147
  } else if (file.name.endsWith(".tpl")) {
124
- await this.processTplFile(srcPath, destPath, {});
148
+ await this.processTplFile(srcPath, destPath, data);
125
149
  } else {
126
150
  throw new Error(
127
151
  "unexpected non tpl file: " + srcPath + " " + file.name
@@ -130,6 +154,7 @@ var CreateProjectCommand = class extends import_clipanion.Command {
130
154
  }
131
155
  }
132
156
  async processTplFile(src, dest, data = {}) {
157
+ import_handlebars.default.registerHelper("eq", (a, b) => a === b);
133
158
  const compiledTemplate = import_handlebars.default.compile(
134
159
  (await fs.readFile(src)).toString()
135
160
  );
@@ -473,7 +473,6 @@ var http_exports = {};
473
473
  __reExport(http_exports, require("@devbro/neko-http"));
474
474
 
475
475
  // src/facades.mts
476
- var yup = __toESM(require("yup"), 1);
477
476
  var import_neko_logger = require("@devbro/neko-logger");
478
477
 
479
478
  // src/factories.mts
@@ -686,24 +685,6 @@ var httpServer = (0, import_neko_helper2.createSingleton)(() => {
686
685
  res.end(JSON.stringify({ message: err.message, error: err.code }));
687
686
  logger().warn({ msg: "HttpError: " + err.message, err });
688
687
  return;
689
- } else if (err instanceof yup.ValidationError) {
690
- res.writeHead(422, { "Content-Type": "application/json" });
691
- const errs = {};
692
- err.inner.forEach((e) => {
693
- const sanitizedParams = { ...e.params };
694
- if (/passw/i.test(e.path)) {
695
- sanitizedParams.value = "******";
696
- sanitizedParams.originalValue = "******";
697
- }
698
- errs[e.path] = {
699
- type: e.type,
700
- message: e.message,
701
- params: sanitizedParams
702
- };
703
- });
704
- res.end(JSON.stringify({ message: "validation error", errors: errs }));
705
- logger().warn({ msg: "ValidationError: " + err.message, err });
706
- return;
707
688
  } else {
708
689
  logger().error({ msg: "Error: " + err.message, err });
709
690
  }
@@ -481,7 +481,6 @@ var http_exports = {};
481
481
  __reExport(http_exports, require("@devbro/neko-http"));
482
482
 
483
483
  // src/facades.mts
484
- var yup = __toESM(require("yup"), 1);
485
484
  var import_neko_logger = require("@devbro/neko-logger");
486
485
 
487
486
  // src/factories.mts
@@ -694,24 +693,6 @@ var httpServer = (0, import_neko_helper2.createSingleton)(() => {
694
693
  res.end(JSON.stringify({ message: err.message, error: err.code }));
695
694
  logger().warn({ msg: "HttpError: " + err.message, err });
696
695
  return;
697
- } else if (err instanceof yup.ValidationError) {
698
- res.writeHead(422, { "Content-Type": "application/json" });
699
- const errs = {};
700
- err.inner.forEach((e) => {
701
- const sanitizedParams = { ...e.params };
702
- if (/passw/i.test(e.path)) {
703
- sanitizedParams.value = "******";
704
- sanitizedParams.originalValue = "******";
705
- }
706
- errs[e.path] = {
707
- type: e.type,
708
- message: e.message,
709
- params: sanitizedParams
710
- };
711
- });
712
- res.end(JSON.stringify({ message: "validation error", errors: errs }));
713
- logger().warn({ msg: "ValidationError: " + err.message, err });
714
- return;
715
696
  } else {
716
697
  logger().error({ msg: "Error: " + err.message, err });
717
698
  }
@@ -482,7 +482,6 @@ var http_exports = {};
482
482
  __reExport(http_exports, require("@devbro/neko-http"));
483
483
 
484
484
  // src/facades.mts
485
- var yup = __toESM(require("yup"), 1);
486
485
  var import_neko_logger = require("@devbro/neko-logger");
487
486
  var import_neko_cache = require("@devbro/neko-cache");
488
487
  var import_neko_queue = require("@devbro/neko-queue");
@@ -523,24 +522,6 @@ var httpServer = (0, import_neko_helper.createSingleton)(() => {
523
522
  res.end(JSON.stringify({ message: err.message, error: err.code }));
524
523
  logger().warn({ msg: "HttpError: " + err.message, err });
525
524
  return;
526
- } else if (err instanceof yup.ValidationError) {
527
- res.writeHead(422, { "Content-Type": "application/json" });
528
- const errs = {};
529
- err.inner.forEach((e) => {
530
- const sanitizedParams = { ...e.params };
531
- if (/passw/i.test(e.path)) {
532
- sanitizedParams.value = "******";
533
- sanitizedParams.originalValue = "******";
534
- }
535
- errs[e.path] = {
536
- type: e.type,
537
- message: e.message,
538
- params: sanitizedParams
539
- };
540
- });
541
- res.end(JSON.stringify({ message: "validation error", errors: errs }));
542
- logger().warn({ msg: "ValidationError: " + err.message, err });
543
- return;
544
525
  } else {
545
526
  logger().error({ msg: "Error: " + err.message, err });
546
527
  }