@expressots/cli 1.6.0 → 1.7.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.
Files changed (54) hide show
  1. package/bin/@types/config.d.ts +9 -0
  2. package/bin/app.container.js +4 -5
  3. package/bin/cli.d.ts +1 -1
  4. package/bin/cli.js +2 -2
  5. package/bin/generate/cli.js +2 -2
  6. package/bin/generate/form.d.ts +13 -0
  7. package/bin/generate/form.js +17 -377
  8. package/bin/generate/templates/nonopinionated/controller.tpl +10 -0
  9. package/bin/generate/templates/nonopinionated/dto.tpl +3 -0
  10. package/bin/generate/templates/nonopinionated/entity.tpl +4 -0
  11. package/bin/generate/templates/nonopinionated/middleware.tpl +10 -0
  12. package/bin/generate/templates/nonopinionated/module.tpl +4 -0
  13. package/bin/generate/templates/nonopinionated/provider.tpl +4 -0
  14. package/bin/generate/templates/nonopinionated/usecase.tpl +8 -0
  15. package/bin/generate/templates/{controller-service-delete.tpl → opinionated/controller-service-delete.tpl} +2 -2
  16. package/bin/generate/templates/{controller-service.tpl → opinionated/controller-service-get.tpl} +2 -2
  17. package/bin/generate/templates/{controller-service-patch.tpl → opinionated/controller-service-patch.tpl} +2 -2
  18. package/bin/generate/templates/{controller-service-post.tpl → opinionated/controller-service-post.tpl} +2 -2
  19. package/bin/generate/templates/{controller-service-put.tpl → opinionated/controller-service-put.tpl} +2 -2
  20. package/bin/generate/templates/{entity.tpl → opinionated/entity.tpl} +2 -2
  21. package/bin/generate/templates/opinionated/usecase-service-delete.tpl +8 -0
  22. package/bin/generate/utils/command-utils.d.ts +123 -0
  23. package/bin/generate/utils/command-utils.js +310 -0
  24. package/bin/generate/utils/nonopininated-cmd.d.ts +9 -0
  25. package/bin/generate/utils/nonopininated-cmd.js +248 -0
  26. package/bin/generate/utils/opinionated-cmd.d.ts +11 -0
  27. package/bin/generate/utils/opinionated-cmd.js +480 -0
  28. package/bin/help/cli.d.ts +4 -0
  29. package/bin/help/cli.js +15 -0
  30. package/bin/help/form.d.ts +2 -0
  31. package/bin/help/form.js +28 -0
  32. package/bin/help/index.d.ts +1 -0
  33. package/bin/help/index.js +2 -0
  34. package/bin/info/form.d.ts +1 -1
  35. package/bin/info/form.js +8 -11
  36. package/bin/new/form.js +1 -0
  37. package/bin/utils/add-controller-to-module.d.ts +1 -2
  38. package/bin/utils/add-module-to-container.d.ts +2 -1
  39. package/bin/utils/add-module-to-container.js +37 -4
  40. package/bin/utils/cli-ui.d.ts +2 -0
  41. package/bin/utils/cli-ui.js +10 -2
  42. package/bin/utils/verify-file-exists.d.ts +1 -1
  43. package/bin/utils/verify-file-exists.js +6 -4
  44. package/package.json +3 -1
  45. package/bin/generate/templates/dto-op.tpl +0 -7
  46. package/bin/generate/templates/usecase-post.tpl +0 -9
  47. /package/bin/generate/templates/{controller.tpl → opinionated/controller-service.tpl} +0 -0
  48. /package/bin/generate/templates/{dto.tpl → opinionated/dto.tpl} +0 -0
  49. /package/bin/generate/templates/{middleware.tpl → opinionated/middleware.tpl} +0 -0
  50. /package/bin/generate/templates/{module.tpl → opinionated/module-service.tpl} +0 -0
  51. /package/bin/generate/templates/{module-default.tpl → opinionated/module.tpl} +0 -0
  52. /package/bin/generate/templates/{provider.tpl → opinionated/provider.tpl} +0 -0
  53. /package/bin/generate/templates/{usecase-op.tpl → opinionated/usecase-service.tpl} +0 -0
  54. /package/bin/generate/templates/{usecase.tpl → opinionated/usecase.tpl} +0 -0
@@ -26,5 +26,14 @@ export interface ExpressoConfig {
26
26
  sourceRoot: string;
27
27
  opinionated: boolean;
28
28
  providers?: IProviders;
29
+ scaffoldSchematics?: {
30
+ entity?: string;
31
+ controller?: string;
32
+ usecase?: string;
33
+ dto?: string;
34
+ module?: string;
35
+ provider?: string;
36
+ middleware?: string;
37
+ };
29
38
  }
30
39
  export {};
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //import { AppContainer } from "@expressots/core";
4
- /*
5
- const appContainer = new AppContainer();
3
+ /* import { AppContainer } from "@expressots/core";
6
4
 
7
- const container = appContainer.create([// Add your modules here, UserModule, UserModule, UserModule]);
5
+ export const appContainer = new AppContainer();
8
6
 
9
- export { container };*/
7
+ export const container = appContainer.create([]);
8
+ */
package/bin/cli.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export declare const CLI_VERSION = "1.3.4";
2
+ export {};
package/bin/cli.js CHANGED
@@ -4,15 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.CLI_VERSION = void 0;
8
7
  const yargs_1 = __importDefault(require("yargs"));
9
8
  const helpers_1 = require("yargs/helpers");
10
9
  const project_commands_1 = require("./commands/project.commands");
11
10
  const generate_1 = require("./generate");
11
+ const cli_1 = require("./help/cli");
12
12
  const info_1 = require("./info");
13
13
  const new_1 = require("./new");
14
14
  const providers_1 = require("./providers");
15
- exports.CLI_VERSION = "1.3.4";
16
15
  console.log(`\n[🐎 Expressots]\n`);
17
16
  (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
18
17
  .scriptName("expressots")
@@ -21,6 +20,7 @@ console.log(`\n[🐎 Expressots]\n`);
21
20
  .command((0, providers_1.generateProviders)())
22
21
  .command((0, generate_1.generateProject)())
23
22
  .command((0, info_1.infoProject)())
23
+ .command((0, cli_1.helpCommand)())
24
24
  .example("$0 new expressots-demo", "Create interactively")
25
25
  .example("$0 new expressots-demo -d ./", "Create interactively with path")
26
26
  .example("$0 new expressots-demo -p yarn -t opinionated", "Create silently")
@@ -18,7 +18,7 @@ const coerceSchematicAliases = (arg) => {
18
18
  return "entity";
19
19
  case "mo":
20
20
  return "module";
21
- case "m":
21
+ case "mi":
22
22
  return "middleware";
23
23
  default:
24
24
  return arg;
@@ -26,7 +26,7 @@ const coerceSchematicAliases = (arg) => {
26
26
  };
27
27
  const generateProject = () => {
28
28
  return {
29
- command: "generate [schematic] [path]",
29
+ command: "generate [schematic] [path] [method]",
30
30
  describe: "Scaffold a new resource",
31
31
  aliases: ["g"],
32
32
  builder: (yargs) => {
@@ -1,7 +1,20 @@
1
+ /**
2
+ * Create a template props
3
+ * @param schematic
4
+ * @param path
5
+ * @param method
6
+ */
1
7
  type CreateTemplateProps = {
2
8
  schematic: string;
3
9
  path: string;
4
10
  method: string;
5
11
  };
12
+ /**
13
+ * Create a template based on the schematic
14
+ * @param schematic - the schematic to create
15
+ * @param path - the path to create the schematic
16
+ * @param method - the http method
17
+ * @returns the file created
18
+ */
6
19
  export declare const createTemplate: ({ schematic, path: target, method, }: CreateTemplateProps) => Promise<string>;
7
20
  export {};
@@ -1,390 +1,30 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __asyncValues = (this && this.__asyncValues) || function (o) {
26
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
27
- var m = o[Symbol.asyncIterator], i;
28
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
29
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
30
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
31
- };
32
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
33
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
4
  };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.createTemplate = void 0;
37
- const nodePath = __importStar(require("path"));
38
- const node_fs_1 = require("node:fs");
39
- const mustache_1 = require("mustache");
40
- const fs_1 = require("fs");
41
- const chalk_1 = __importDefault(require("chalk"));
42
- const boost_ts_1 = require("@expressots/boost-ts");
43
7
  const compiler_1 = __importDefault(require("../utils/compiler"));
44
- const add_controller_to_module_1 = require("../utils/add-controller-to-module");
45
- const verify_file_exists_1 = require("../utils/verify-file-exists");
46
- const add_module_to_container_1 = require("../utils/add-module-to-container");
47
- const cli_ui_1 = require("../utils/cli-ui");
48
- function getFileNameWithoutExtension(filePath) {
49
- return filePath.split(".")[0];
50
- }
8
+ const command_utils_1 = require("./utils/command-utils");
9
+ const nonopininated_cmd_1 = require("./utils/nonopininated-cmd");
10
+ const opinionated_cmd_1 = require("./utils/opinionated-cmd");
11
+ /**
12
+ * Create a template based on the schematic
13
+ * @param schematic - the schematic to create
14
+ * @param path - the path to create the schematic
15
+ * @param method - the http method
16
+ * @returns the file created
17
+ */
51
18
  const createTemplate = async ({ schematic, path: target, method, }) => {
52
- var _a, e_1, _b, _c;
53
- const { opinionated, sourceRoot } = await compiler_1.default.loadConfig();
54
- if (sourceRoot === "") {
55
- (0, cli_ui_1.printError)("You must specify a source root in your expressots.config.ts", "sourceRoot");
56
- process.exit(1);
57
- }
58
- let folderMatch = "";
59
- if (opinionated) {
60
- folderMatch = schematicFolder(schematic);
61
- }
62
- else {
63
- folderMatch = "";
64
- }
65
- const { path, file, className, moduleName, modulePath } = await splitTarget({ target, schematic });
66
- const usecaseDir = `${sourceRoot}/${folderMatch}`;
67
- await (0, verify_file_exists_1.verifyIfFileExists)(`${usecaseDir}/${path}/${file}`);
68
- (0, node_fs_1.mkdirSync)(`${usecaseDir}/${path}`, { recursive: true });
69
- if (schematic !== "service") {
70
- // add to guarantee that the routing will always be the last part of the path
71
- let routeSchema = "";
72
- if (target.includes("/") ||
73
- target.includes("\\") ||
74
- target.includes("//")) {
75
- routeSchema = path.split("/").pop();
76
- }
77
- else {
78
- routeSchema = path.replace(/\/$/, "");
79
- }
80
- let templateBasedSchematic = schematic;
81
- if (schematic === "module") {
82
- templateBasedSchematic = "module-default";
83
- }
84
- writeTemplate({
85
- outputPath: `${usecaseDir}/${path}/${file}`,
86
- template: {
87
- path: `./templates/${templateBasedSchematic}.tpl`,
88
- data: {
89
- className,
90
- moduleName: className,
91
- route: routeSchema,
92
- construct: (0, boost_ts_1.anyCaseToKebabCase)(className),
93
- method: getHttpMethod(method),
94
- },
95
- },
96
- });
97
- }
98
- else {
99
- try {
100
- for (var _d = true, _e = __asyncValues(["controller-service", "usecase", "dto"]), _f; _f = await _e.next(), _a = _f.done, !_a;) {
101
- _c = _f.value;
102
- _d = false;
103
- try {
104
- const resource = _c;
105
- const currentSchematic = resource.replace("controller-service", "controller");
106
- const schematicFile = file.replace(`controller.ts`, `${currentSchematic}.ts`);
107
- console.log(" ", chalk_1.default.greenBright(`[${currentSchematic}]`.padEnd(14)), chalk_1.default.bold.white(`${schematicFile} created! ✔️`));
108
- let templateBasedMethod = "";
109
- if (method) {
110
- if (resource === "controller-service" ||
111
- resource === "controller") {
112
- if (method === "get")
113
- templateBasedMethod = `./templates/${resource}.tpl`;
114
- else
115
- templateBasedMethod = `./templates/${resource}-${method}.tpl`;
116
- }
117
- else {
118
- templateBasedMethod = `./templates/${resource}.tpl`;
119
- }
120
- if (resource === "usecase") {
121
- templateBasedMethod = `./templates/${resource}-op.tpl`;
122
- }
123
- if (resource === "usecase") {
124
- if (method === "get")
125
- templateBasedMethod = `./templates/${resource}.tpl`;
126
- if (method === "post")
127
- templateBasedMethod = `./templates/${resource}-${method}.tpl`;
128
- }
129
- }
130
- else {
131
- templateBasedMethod = `./templates/${resource}.tpl`;
132
- }
133
- // add to guarantee that the routing will always be the last part of the path
134
- let routeSchema = "";
135
- if (target.includes("/") ||
136
- target.includes("\\") ||
137
- target.includes("//")) {
138
- routeSchema = path.split("/").pop();
139
- }
140
- else {
141
- routeSchema = path.replace(/\/$/, "");
142
- }
143
- writeTemplate({
144
- outputPath: `${usecaseDir}/${path}/${schematicFile}`,
145
- template: {
146
- path: templateBasedMethod,
147
- data: {
148
- className,
149
- fileName: getFileNameWithoutExtension(file),
150
- useCase: (0, boost_ts_1.anyCaseToCamelCase)(className),
151
- route: routeSchema,
152
- construct: (0, boost_ts_1.anyCaseToKebabCase)(className),
153
- method: getHttpMethod(method),
154
- },
155
- },
156
- });
157
- }
158
- finally {
159
- _d = true;
160
- }
161
- }
162
- }
163
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
164
- finally {
165
- try {
166
- if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
167
- }
168
- finally { if (e_1) throw e_1.error; }
169
- }
170
- }
171
- // Module generation
172
- if (["controller", "service"].includes(schematic)) {
173
- let moduleExist = false;
174
- let moduleOutPath = "";
175
- if (target.includes("/") ||
176
- target.includes("\\") ||
177
- target.includes("//")) {
178
- if (modulePath === "") {
179
- moduleExist = (0, fs_1.existsSync)(`${usecaseDir}/${moduleName}.module.ts`);
180
- moduleOutPath = `${usecaseDir}/${moduleName}.module.ts`;
181
- }
182
- else {
183
- moduleExist = (0, fs_1.existsSync)(`${usecaseDir}/${modulePath}/${moduleName}.module.ts`);
184
- moduleOutPath = `${usecaseDir}/${modulePath}/${moduleName}.module.ts`;
185
- }
186
- }
187
- else {
188
- moduleExist = (0, fs_1.existsSync)(`${usecaseDir}/${moduleName}/${moduleName}.module.ts`);
189
- if (modulePath === "") {
190
- moduleExist = (0, fs_1.existsSync)(`${usecaseDir}/${moduleName}.module.ts`);
191
- moduleOutPath = `${usecaseDir}/${moduleName}.module.ts`;
192
- }
193
- else {
194
- moduleExist = (0, fs_1.existsSync)(`${usecaseDir}/${moduleName}/${moduleName}.module.ts`);
195
- moduleOutPath = `${usecaseDir}/${moduleName}/${moduleName}.module.ts`;
196
- }
197
- }
198
- let controllerPath = "./";
199
- const pathCount = path.split("/").length;
200
- if (path === "") {
201
- controllerPath += `${file.slice(0, file.lastIndexOf("."))}`;
202
- }
203
- else if (pathCount === 1) {
204
- controllerPath += `${path}/${file.slice(0, file.lastIndexOf("."))}`;
205
- }
206
- else if (pathCount === 2) {
207
- controllerPath += `${path.split("/")[1]}/${file.slice(0, file.lastIndexOf("."))}`;
208
- }
209
- else {
210
- const segments = path
211
- .split("/")
212
- .filter((segment) => segment !== "");
213
- controllerPath += `${segments[segments.length - 1]}/${file.slice(0, file.lastIndexOf("."))}`;
214
- }
215
- if (moduleExist) {
216
- if (target.includes("/") ||
217
- target.includes("\\") ||
218
- target.includes("//")) {
219
- await (0, add_controller_to_module_1.addControllerToModule)(`${usecaseDir}/${modulePath}/${moduleName}.module.ts`, `${className}Controller`, controllerPath);
220
- }
221
- else {
222
- if (modulePath === "") {
223
- await (0, add_controller_to_module_1.addControllerToModule)(`${usecaseDir}/${moduleName}.module.ts`, `${className}Controller`, controllerPath);
224
- }
225
- else {
226
- await (0, add_controller_to_module_1.addControllerToModule)(`${usecaseDir}/${moduleName}/${moduleName}.module.ts`, `${className}Controller`, controllerPath);
227
- }
228
- }
229
- }
230
- else {
231
- writeTemplate({
232
- outputPath: moduleOutPath,
233
- template: {
234
- path: `./templates/module.tpl`,
235
- data: {
236
- moduleName: moduleName[0].toUpperCase() + moduleName.slice(1),
237
- className,
238
- path: controllerPath,
239
- },
240
- },
241
- });
242
- console.log(" ", chalk_1.default.greenBright(`[module]`.padEnd(14)), chalk_1.default.bold.white(`${moduleName}.module created! ✔️`));
243
- if (target.includes("/") ||
244
- target.includes("\\") ||
245
- target.includes("//")) {
246
- await (0, add_module_to_container_1.addModuleToContainer)(moduleName, modulePath, path);
247
- }
248
- else {
249
- await (0, add_module_to_container_1.addModuleToContainer)(moduleName, moduleName, path);
250
- }
251
- }
252
- }
253
- if (schematic === "service") {
254
- console.log(" ", chalk_1.default.greenBright(`[${schematic}]`.padEnd(14)), chalk_1.default.bold.yellow(`${file.split(".")[0]} created! ✔️`));
19
+ const config = await compiler_1.default.loadConfig();
20
+ const pathStyle = (0, command_utils_1.checkPathStyle)(target);
21
+ let returnFile = "";
22
+ if (config.opinionated) {
23
+ returnFile = await (0, opinionated_cmd_1.opinionatedProcess)(schematic, target, method, config, pathStyle);
255
24
  }
256
25
  else {
257
- console.log(" ", chalk_1.default.greenBright(`[${schematic}]`.padEnd(14)), chalk_1.default.bold.white(`${file.split(".")[0]} ${schematic} created! ✔️`));
26
+ returnFile = await (0, nonopininated_cmd_1.nonOpinionatedProcess)(schematic, target, method, config);
258
27
  }
259
- return file;
28
+ return returnFile;
260
29
  };
261
30
  exports.createTemplate = createTemplate;
262
- const splitTarget = async ({ target, schematic, }) => {
263
- const pathContent = target
264
- .split("/")
265
- .filter((item) => item !== "");
266
- const endsWithSlash = target.endsWith("/");
267
- let path = "";
268
- let fileName = "";
269
- let module = "";
270
- let modulePath = "";
271
- if (target.includes("/") ||
272
- target.includes("\\") ||
273
- target.includes("//")) {
274
- if (schematic === "service")
275
- schematic = "controller";
276
- if (schematic === "service" ||
277
- (schematic === "controller" && pathContent.length > 4)) {
278
- (0, cli_ui_1.printError)("Max path depth is 4.", pathContent.join("/"));
279
- process.exit(1);
280
- }
281
- if (endsWithSlash) {
282
- fileName = pathContent[pathContent.length - 1];
283
- path = pathContent.join("/");
284
- module =
285
- pathContent.length == 1
286
- ? pathContent[pathContent.length - 1]
287
- : pathContent[pathContent.length - 2];
288
- modulePath = pathContent.slice(0, -1).join("/");
289
- }
290
- else {
291
- fileName = pathContent[pathContent.length - 1];
292
- path = pathContent.slice(0, -1).join("/");
293
- module =
294
- pathContent.length == 2
295
- ? pathContent[pathContent.length - 2]
296
- : pathContent[pathContent.length - 3];
297
- modulePath = pathContent.slice(0, -2).join("/");
298
- }
299
- return {
300
- path,
301
- file: `${await getNameWithScaffoldPattern(fileName)}.${schematic}.ts`,
302
- className: (0, boost_ts_1.anyCaseToPascalCase)(fileName),
303
- moduleName: module,
304
- modulePath,
305
- };
306
- }
307
- else {
308
- if (schematic === "service")
309
- schematic = "controller";
310
- // 1. Extract the name (first part of the target)
311
- const [name, ...remainingPath] = target.split("/");
312
- // 2. Check if the name is camelCase or kebab-case
313
- const camelCaseRegex = /[A-Z]/;
314
- const kebabCaseRegex = /[_\-\s]+/;
315
- const isCamelCase = camelCaseRegex.test(name);
316
- const isKebabCase = kebabCaseRegex.test(name);
317
- if (isCamelCase || isKebabCase) {
318
- const [wordName, ...path] = name === null || name === void 0 ? void 0 : name.split(isCamelCase ? /(?=[A-Z])/ : kebabCaseRegex).map((word) => word.toLowerCase());
319
- return {
320
- path: `${wordName}/${pathEdgeCase(path)}${pathEdgeCase(remainingPath)}`,
321
- file: `${await getNameWithScaffoldPattern(name)}.${schematic}.ts`,
322
- className: (0, boost_ts_1.anyCaseToPascalCase)(name),
323
- moduleName: wordName,
324
- modulePath: pathContent[0].split("-")[1],
325
- };
326
- }
327
- // 3. Return the base case
328
- return {
329
- path: "",
330
- file: `${await getNameWithScaffoldPattern(name)}.${schematic}.ts`,
331
- className: (0, boost_ts_1.anyCaseToPascalCase)(name),
332
- moduleName: name,
333
- modulePath: "",
334
- };
335
- }
336
- };
337
- const getHttpMethod = (method) => {
338
- switch (method) {
339
- case "put":
340
- return "Put";
341
- case "post":
342
- return "Post";
343
- case "patch":
344
- return "Patch";
345
- case "delete":
346
- return "Delete";
347
- default:
348
- return "Get";
349
- }
350
- };
351
- const writeTemplate = ({ outputPath, template: { path, data }, }) => {
352
- (0, fs_1.writeFileSync)(outputPath, (0, mustache_1.render)((0, node_fs_1.readFileSync)(nodePath.join(__dirname, path), "utf8"), data));
353
- };
354
- const schematicFolder = (schematic) => {
355
- switch (schematic) {
356
- case "usecase":
357
- return "useCases";
358
- case "controller":
359
- return "useCases";
360
- case "dto":
361
- return "useCases";
362
- case "service":
363
- return "useCases";
364
- case "provider":
365
- return "providers";
366
- case "entity":
367
- return "entities";
368
- case "middleware":
369
- return "providers/middlewares";
370
- case "module":
371
- return "useCases";
372
- }
373
- return undefined;
374
- };
375
- const getNameWithScaffoldPattern = async (name) => {
376
- const configObject = await compiler_1.default.loadConfig();
377
- switch (configObject.scaffoldPattern) {
378
- case "lowercase" /* Pattern.LOWER_CASE */:
379
- return (0, boost_ts_1.anyCaseToLowerCase)(name);
380
- case "kebab-case" /* Pattern.KEBAB_CASE */:
381
- return (0, boost_ts_1.anyCaseToKebabCase)(name);
382
- case "PascalCase" /* Pattern.PASCAL_CASE */:
383
- return (0, boost_ts_1.anyCaseToPascalCase)(name);
384
- case "camelCase" /* Pattern.CAMEL_CASE */:
385
- return (0, boost_ts_1.anyCaseToCamelCase)(name);
386
- }
387
- };
388
- const pathEdgeCase = (path) => {
389
- return `${path.join("/")}${path.length > 0 ? "/" : ""}`;
390
- };
@@ -0,0 +1,10 @@
1
+ import { BaseController } from "@expressots/core";
2
+ import { controller, {{method}} } from "@expressots/adapter-express";
3
+
4
+ @controller("/{{{route}}}")
5
+ export class {{className}}{{schematic}} {
6
+ @{{method}}("/")
7
+ execute() {
8
+ return "{{schematic}}";
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ export interface I{{className}}Request{{schematic}} {}
2
+
3
+ export interface I{{className}}Response{{schematic}} {}
@@ -0,0 +1,4 @@
1
+ import { provide } from "inversify-binding-decorators";
2
+
3
+ @provide({{className}}{{schematic}})
4
+ export class {{className}}{{schematic}} {}
@@ -0,0 +1,10 @@
1
+ import { ExpressoMiddleware } from "@expressots/core";
2
+ import { NextFunction, Request, Response } from "express";
3
+ import { provide } from "inversify-binding-decorators";
4
+
5
+ @provide({{className}}{{schematic}})
6
+ export class {{className}}{{schematic}} extends ExpressoMiddleware {
7
+ use(req: Request, res: Response, next: NextFunction): void | Promise<void> {
8
+ throw new Error("Method not implemented.");
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ import { ContainerModule } from "inversify";
2
+ import { CreateModule } from "@expressots/core";
3
+
4
+ export const {{moduleName}}{{schematic}}: ContainerModule = CreateModule([]);
@@ -0,0 +1,4 @@
1
+ import { provide } from "inversify-binding-decorators";
2
+
3
+ @provide({{className}}{{schematic}})
4
+ export class {{className}}{{schematic}} {}
@@ -0,0 +1,8 @@
1
+ import { provide } from "inversify-binding-decorators";
2
+
3
+ @provide({{className}}{{schematic}})
4
+ export class {{className}}{{schematic}} {
5
+ execute() {
6
+ return "{{schematic}}";
7
+ }
8
+ }
@@ -1,5 +1,5 @@
1
1
  import { BaseController, StatusCode } from "@expressots/core";
2
- import { controller, {{method}}, param, response } from "@expressots/adapter-express";
2
+ import { controller, Delete, param, response } from "@expressots/adapter-express";
3
3
  import { Response } from "express";
4
4
  import { {{className}}UseCase } from "./{{fileName}}.usecase";
5
5
  import { I{{className}}RequestDTO, I{{className}}ResponseDTO } from "./{{fileName}}.dto";
@@ -10,7 +10,7 @@ export class {{className}}Controller extends BaseController {
10
10
  super();
11
11
  }
12
12
 
13
- @{{method}}("/:id")
13
+ @Delete("/:id")
14
14
  execute(@param("id") id: string, @response() res: Response): I{{className}}ResponseDTO {
15
15
  return this.callUseCase(
16
16
  this.{{useCase}}UseCase.execute(id),
@@ -1,5 +1,5 @@
1
1
  import { BaseController, StatusCode } from "@expressots/core";
2
- import { controller, {{method}}, response } from "@expressots/adapter-express";
2
+ import { controller, Get, response } from "@expressots/adapter-express";
3
3
  import { Response } from "express";
4
4
  import { {{className}}UseCase } from "./{{fileName}}.usecase";
5
5
  import { I{{className}}ResponseDTO } from "./{{fileName}}.dto";
@@ -10,7 +10,7 @@ export class {{className}}Controller extends BaseController {
10
10
  super();
11
11
  }
12
12
 
13
- @{{method}}("/")
13
+ @Get("/")
14
14
  execute(@response() res: Response): I{{className}}ResponseDTO {
15
15
  return this.callUseCase(
16
16
  this.{{useCase}}UseCase.execute(),
@@ -1,5 +1,5 @@
1
1
  import { BaseController, StatusCode } from "@expressots/core";
2
- import { controller, {{method}}, body, param, response } from "@expressots/adapter-express";
2
+ import { controller, Patch, body, param, response } from "@expressots/adapter-express";
3
3
  import { Response } from "express";
4
4
  import { {{className}}UseCase } from "./{{fileName}}.usecase";
5
5
  import { I{{className}}RequestDTO, I{{className}}ResponseDTO } from "./{{fileName}}.dto";
@@ -10,7 +10,7 @@ export class {{className}}Controller extends BaseController {
10
10
  super();
11
11
  }
12
12
 
13
- @{{method}}("/")
13
+ @Patch("/")
14
14
  execute(
15
15
  @body() payload: I{{className}}RequestDTO,
16
16
  @response() res: Response,
@@ -1,5 +1,5 @@
1
1
  import { BaseController, StatusCode } from "@expressots/core";
2
- import { controller, {{method}}, body, response } from "@expressots/adapter-express";
2
+ import { controller, Post, body, response } from "@expressots/adapter-express";
3
3
  import { Response } from "express";
4
4
  import { {{className}}UseCase } from "./{{fileName}}.usecase";
5
5
  import { I{{className}}RequestDTO, I{{className}}ResponseDTO } from "./{{fileName}}.dto";
@@ -10,7 +10,7 @@ export class {{className}}Controller extends BaseController {
10
10
  super();
11
11
  }
12
12
 
13
- @{{method}}("/")
13
+ @Post("/")
14
14
  execute(@body() payload: I{{className}}RequestDTO, @response() res: Response): I{{className}}ResponseDTO {
15
15
  return this.callUseCase(
16
16
  this.{{useCase}}UseCase.execute(payload),
@@ -1,5 +1,5 @@
1
1
  import { BaseController, StatusCode } from "@expressots/core";
2
- import { controller, {{method}}, body, param, response } from "@expressots/adapter-express";
2
+ import { controller, Put, body, param, response } from "@expressots/adapter-express";
3
3
  import { Response } from "express";
4
4
  import { {{className}}UseCase } from "./{{fileName}}.usecase";
5
5
  import { I{{className}}RequestDTO, I{{className}}ResponseDTO } from "./{{fileName}}.dto";
@@ -10,7 +10,7 @@ export class {{className}}Controller extends BaseController {
10
10
  super();
11
11
  }
12
12
 
13
- @{{method}}("/")
13
+ @Put("/")
14
14
  execute(
15
15
  @body() payload: I{{className}}RequestDTO,
16
16
  @response() res: Response,
@@ -1,8 +1,8 @@
1
1
  import { provide } from "inversify-binding-decorators";
2
2
  import { randomUUID } from "node:crypto";
3
3
 
4
- @provide({{className}})
5
- export class {{className}} {
4
+ @provide({{className}}Entity)
5
+ export class {{className}}Entity {
6
6
  id: string;
7
7
 
8
8
  constructor() {