db-model-router 1.0.9 → 1.0.10

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.
Binary file
Binary file
@@ -384,9 +384,9 @@
384
384
  "license": "MIT"
385
385
  },
386
386
  "node_modules/better-sqlite3": {
387
- "version": "12.9.0",
388
- "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-12.9.0.tgz",
389
- "integrity": "sha512-wqUv4Gm3toFpHDQmaKD4QhZm3g1DjUBI0yzS4UBl6lElUmXFYdTQmmEDpAFa5o8FiFiymURypEnfVHzILKaxqQ==",
387
+ "version": "12.10.0",
388
+ "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-12.10.0.tgz",
389
+ "integrity": "sha512-CyzaZRQKyHkB2ZInfTTl2nvT33EbDpjkLEbE8/Zck3Ll6O0qqvuGdrJ45HgtH+HykRg88ITY3AdreBGN70aBSQ==",
390
390
  "hasInstallScript": true,
391
391
  "license": "MIT",
392
392
  "dependencies": {
@@ -394,7 +394,7 @@
394
394
  "prebuild-install": "^7.1.1"
395
395
  },
396
396
  "engines": {
397
- "node": "20.x || 22.x || 23.x || 24.x || 25.x"
397
+ "node": "20.x || 22.x || 23.x || 24.x || 25.x || 26.x"
398
398
  }
399
399
  },
400
400
  "node_modules/binary-extensions": {
@@ -837,9 +837,9 @@
837
837
  }
838
838
  },
839
839
  "node_modules/db-model-router": {
840
- "version": "1.0.8",
841
- "resolved": "https://registry.npmjs.org/db-model-router/-/db-model-router-1.0.8.tgz",
842
- "integrity": "sha512-rqC6waXrC0Do7e6mMFHJ286moO5VETOaDM4TlYR8kvNg+XGBHKw1rRzp9pGEEzaiZVSYbTTj/snXmZSh695dRw==",
840
+ "version": "1.0.9",
841
+ "resolved": "https://registry.npmjs.org/db-model-router/-/db-model-router-1.0.9.tgz",
842
+ "integrity": "sha512-bqvNothqxY8jvRrxzDvYM3RCo7gN0uvIKah1JHXCu0giXMrzuPangQZzhcJPWrKD4SD+KSWM53G7yd9dCgfduQ==",
843
843
  "license": "Apache-2.0",
844
844
  "dependencies": {
845
845
  "dotenv": "^10.0.0",
@@ -1305,9 +1305,9 @@
1305
1305
  }
1306
1306
  },
1307
1307
  "node_modules/express-rate-limit": {
1308
- "version": "8.5.1",
1309
- "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.5.1.tgz",
1310
- "integrity": "sha512-5O6KYmyJEpuPJV5hNTXKbAHWRqrzyu+OI3vUnSd2kXFubIVpG7ezpgxQy76Zo5GQZtrQBg86hF+CM/NX+cioiQ==",
1308
+ "version": "8.5.2",
1309
+ "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.5.2.tgz",
1310
+ "integrity": "sha512-5Kb34ipNX694DH48vN9irak1Qx30nb0PLYHXfJgw4YEjiC3ZEmZJhwOp+VfiCYwFzvFTdB9QkArYS5kXa2cx2A==",
1311
1311
  "license": "MIT",
1312
1312
  "dependencies": {
1313
1313
  "ip-address": "^10.2.0"
@@ -2876,9 +2876,9 @@
2876
2876
  }
2877
2877
  },
2878
2878
  "node_modules/qs": {
2879
- "version": "6.15.1",
2880
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.1.tgz",
2881
- "integrity": "sha512-6YHEFRL9mfgcAvql/XhwTvf5jKcOiiupt2FiJxHkiX1z4j7WL8J/jRHYLluORvc1XxB5rV20KoeK00gVJamspg==",
2879
+ "version": "6.15.2",
2880
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
2881
+ "integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
2882
2882
  "license": "BSD-3-Clause",
2883
2883
  "dependencies": {
2884
2884
  "side-channel": "^1.1.0"
@@ -3562,9 +3562,9 @@
3562
3562
  }
3563
3563
  },
3564
3564
  "node_modules/swagger-ui-dist": {
3565
- "version": "5.32.5",
3566
- "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.32.5.tgz",
3567
- "integrity": "sha512-7/FQfWe9A4qoyYFdAwy0chD0uDYidDp/ZT9VQ9LZlgD4AnnHJk8/+ytAA1HkJYOPySmK6helPDdJQMlcumt7HA==",
3565
+ "version": "5.32.6",
3566
+ "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.32.6.tgz",
3567
+ "integrity": "sha512-75ttZNaYCLoFPnozPZcTUU6mS3wKT8l7WLjU5zJSHFeJa23i5vtnze6IiCl4jDMPeQTXVXIgovq4M11NNfQvSA==",
3568
3568
  "license": "Apache-2.0",
3569
3569
  "dependencies": {
3570
3570
  "@scarf/scarf": "=1.4.0"
@@ -3714,17 +3714,34 @@
3714
3714
  }
3715
3715
  },
3716
3716
  "node_modules/type-is": {
3717
- "version": "2.0.1",
3718
- "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz",
3719
- "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==",
3717
+ "version": "2.1.0",
3718
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz",
3719
+ "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==",
3720
3720
  "license": "MIT",
3721
3721
  "dependencies": {
3722
- "content-type": "^1.0.5",
3722
+ "content-type": "^2.0.0",
3723
3723
  "media-typer": "^1.1.0",
3724
3724
  "mime-types": "^3.0.0"
3725
3725
  },
3726
3726
  "engines": {
3727
- "node": ">= 0.6"
3727
+ "node": ">= 18"
3728
+ },
3729
+ "funding": {
3730
+ "type": "opencollective",
3731
+ "url": "https://opencollective.com/express"
3732
+ }
3733
+ },
3734
+ "node_modules/type-is/node_modules/content-type": {
3735
+ "version": "2.0.0",
3736
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",
3737
+ "integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",
3738
+ "license": "MIT",
3739
+ "engines": {
3740
+ "node": ">=18"
3741
+ },
3742
+ "funding": {
3743
+ "type": "opencollective",
3744
+ "url": "https://opencollective.com/express"
3728
3745
  }
3729
3746
  },
3730
3747
  "node_modules/uid-safe": {
@@ -13,7 +13,7 @@ const SUPER_ADMIN_EMAIL = "admin@system.local";
13
13
  * Generated password for the Super Admin.
14
14
  * This is cryptographically random and unique per generation.
15
15
  */
16
- const SUPER_ADMIN_PASSWORD = "812fed18236314a46972a977b60c69a5";
16
+ const SUPER_ADMIN_PASSWORD = "d8a53d980af3a1516a211b4875dcec77";
17
17
 
18
18
  /**
19
19
  * Super Admin permissions: all actions for all modules with global scope.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "db-model-router",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Generative API Creation using mysql2 and express libraries in node js",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -153,30 +153,30 @@ async function generate(args, flags, ctx) {
153
153
  childrenByParent[rel.parent].push(rel);
154
154
  }
155
155
 
156
- // Generate route files for each table (top-level only, skip children)
156
+ // Generate route files for each table
157
157
  for (const m of meta) {
158
158
  if (nestedChildren.has(m.table)) continue;
159
159
 
160
160
  const children = childrenByParent[m.table] || [];
161
161
  if (children.length > 0) {
162
- // Parent with children: generates route that mounts child routes
162
+ // Parent with children: generates index.js that mounts child routes
163
163
  planned.push({
164
- relPath: `routes/${m.table}.js`,
164
+ relPath: `routes/${m.table}/index.js`,
165
165
  content: generateParentRouteFile(m.table, children),
166
166
  });
167
167
  } else {
168
168
  // Simple table: just CRUD
169
169
  planned.push({
170
- relPath: `routes/${m.table}.js`,
170
+ relPath: `routes/${m.table}/index.js`,
171
171
  content: generateRouteFile(m.table),
172
172
  });
173
173
  }
174
174
  }
175
175
 
176
- // Child route files inside parent folders: routes/<parent>/<child>.js
176
+ // Child route files inside parent folders: routes/<parent>/<child>/index.js
177
177
  for (const rel of relationships) {
178
178
  planned.push({
179
- relPath: `routes/${rel.parent}/${rel.child}.js`,
179
+ relPath: `routes/${rel.parent}/${rel.child}/index.js`,
180
180
  content: generateChildRouteFile(rel.child, rel.parent, rel.foreignKey),
181
181
  });
182
182
  }
@@ -74,21 +74,21 @@ function buildExpectedFiles(meta, relationships) {
74
74
  const children = childrenByParent[m.table] || [];
75
75
  if (children.length > 0) {
76
76
  expected.set(
77
- `routes/${m.table}.js`,
77
+ `routes/${m.table}/index.js`,
78
78
  generateParentRouteFile(m.table, children),
79
79
  );
80
80
  } else {
81
81
  expected.set(
82
- `routes/${m.table}.js`,
82
+ `routes/${m.table}/index.js`,
83
83
  generateRouteFile(m.table, modelsRelPath),
84
84
  );
85
85
  }
86
86
  }
87
87
 
88
- // Child route files in subfolders: routes/<parent>/<child>.js
88
+ // Child route files inside parent folders: routes/<parent>/<child>/index.js
89
89
  for (const rel of relationships) {
90
90
  expected.set(
91
- `routes/${rel.parent}/${rel.child}.js`,
91
+ `routes/${rel.parent}/${rel.child}/index.js`,
92
92
  generateChildRouteFile(
93
93
  rel.child,
94
94
  rel.parent,
@@ -40,7 +40,7 @@ export default router;
40
40
 
41
41
  /**
42
42
  * Generate a parent route file that includes its own CRUD and mounts child routes.
43
- * e.g., routes/users.js mounts posts under /:user_id/posts
43
+ * e.g., routes/orders/index.js mounts order_items under /:order_id/items
44
44
  *
45
45
  * @param {string} tableName - Parent table name
46
46
  * @param {Array<{child, foreignKey}>} children - Child relationships for this parent
@@ -56,7 +56,7 @@ import { ${varName} } from "#models";
56
56
  // Import child routes
57
57
  for (const child of children) {
58
58
  const childVar = safeVarName(child.child);
59
- code += `import ${childVar}Route from "./${tableName}/${child.child}.js";\n`;
59
+ code += `import ${childVar}Route from "./${child.child}/index.js";\n`;
60
60
  }
61
61
 
62
62
  code += `
@@ -129,7 +129,7 @@ function generateRoutesIndexFile(tableNames, relationships = [], options = {}) {
129
129
  for (const table of tableNames) {
130
130
  if (nestedChildren.has(table)) continue;
131
131
  const varName = safeVarName(table);
132
- imports += `import ${varName}Route from "./${table}.js";\n`;
132
+ imports += `import ${varName}Route from "./${table}/index.js";\n`;
133
133
  }
134
134
 
135
135
  // Import docs route if openapi is generated