create-backlist 6.1.9 → 6.2.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/package.json +1 -1
- package/src/generators/node.js +6 -11
package/package.json
CHANGED
package/src/generators/node.js
CHANGED
|
@@ -12,7 +12,6 @@ function stripQuery(p) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function safePascalName(name) {
|
|
15
|
-
// remove query + invalid filename chars, keep alphanumerics only
|
|
16
15
|
const cleaned = String(name || "Default")
|
|
17
16
|
.split("?")[0]
|
|
18
17
|
.replace(/[^a-zA-Z0-9]/g, "");
|
|
@@ -25,10 +24,8 @@ function sanitizeEndpoints(endpoints) {
|
|
|
25
24
|
if (!Array.isArray(endpoints)) return [];
|
|
26
25
|
|
|
27
26
|
return endpoints.map((ep) => {
|
|
28
|
-
// IMPORTANT: strip query string so it never leaks into names
|
|
29
27
|
const rawPath = stripQuery(ep.path || ep.route || "/");
|
|
30
28
|
|
|
31
|
-
// remove empty, api, and version segments (v1/v2/v10...)
|
|
32
29
|
const parts = rawPath
|
|
33
30
|
.split("/")
|
|
34
31
|
.filter(Boolean)
|
|
@@ -39,7 +36,6 @@ function sanitizeEndpoints(endpoints) {
|
|
|
39
36
|
|
|
40
37
|
let functionName = "";
|
|
41
38
|
|
|
42
|
-
// AUTH naming
|
|
43
39
|
if (controllerName.toLowerCase() === "auth") {
|
|
44
40
|
if (rawPath.includes("login")) functionName = "loginUser";
|
|
45
41
|
else if (rawPath.includes("register")) functionName = "registerUser";
|
|
@@ -54,9 +50,9 @@ function sanitizeEndpoints(endpoints) {
|
|
|
54
50
|
const method = String(ep.method || "GET").toUpperCase();
|
|
55
51
|
|
|
56
52
|
const hasId =
|
|
57
|
-
rawPath.includes(":") ||
|
|
58
|
-
rawPath.includes("{") ||
|
|
59
|
-
/\/\d+/.test(rawPath);
|
|
53
|
+
rawPath.includes(":") ||
|
|
54
|
+
rawPath.includes("{") ||
|
|
55
|
+
/\/\d+/.test(rawPath);
|
|
60
56
|
|
|
61
57
|
if (method === "GET") {
|
|
62
58
|
functionName = hasId ? `get${pascalSingular}ById` : `getAll${pascalPlural}`;
|
|
@@ -71,7 +67,6 @@ function sanitizeEndpoints(endpoints) {
|
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
69
|
|
|
74
|
-
// return with clean path (query removed)
|
|
75
70
|
return { ...ep, path: rawPath, controllerName, functionName };
|
|
76
71
|
});
|
|
77
72
|
}
|
|
@@ -107,7 +102,6 @@ async function generateNodeProject(options) {
|
|
|
107
102
|
|
|
108
103
|
endpoints.forEach((ep) => {
|
|
109
104
|
if (!ep) return;
|
|
110
|
-
|
|
111
105
|
const ctrl = safePascalName(ep.controllerName);
|
|
112
106
|
if (ctrl === "Default" || ctrl === "Auth") return;
|
|
113
107
|
|
|
@@ -263,7 +257,7 @@ async function generateNodeProject(options) {
|
|
|
263
257
|
);
|
|
264
258
|
}
|
|
265
259
|
|
|
266
|
-
// --- Step 8: Extras ---
|
|
260
|
+
// --- Step 8: Extras (FIXED) ---
|
|
267
261
|
if (extraFeatures.includes("docker")) {
|
|
268
262
|
console.log(chalk.blue(" -> Generating Docker files..."));
|
|
269
263
|
await renderAndWrite(
|
|
@@ -281,10 +275,11 @@ async function generateNodeProject(options) {
|
|
|
281
275
|
if (extraFeatures.includes("swagger")) {
|
|
282
276
|
console.log(chalk.blue(" -> Generating API documentation setup..."));
|
|
283
277
|
await fs.ensureDir(path.join(destSrcDir, "utils"));
|
|
278
|
+
// FIX: Added 'paths' to the EJS data object
|
|
284
279
|
await renderAndWrite(
|
|
285
280
|
getTemplatePath("node-ts-express/partials/ApiDocs.ts.ejs"),
|
|
286
281
|
path.join(destSrcDir, "utils", "swagger.ts"),
|
|
287
|
-
{ projectName, port, addAuth }
|
|
282
|
+
{ projectName, port, addAuth, paths: endpoints }
|
|
288
283
|
);
|
|
289
284
|
}
|
|
290
285
|
|