maxserver 0.1.15 → 0.1.17
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/setup.js +1 -0
- package/src/setupDocs.js +1 -0
- package/src/setupRoutes.js +17 -0
package/package.json
CHANGED
package/src/setup.js
CHANGED
package/src/setupDocs.js
CHANGED
package/src/setupRoutes.js
CHANGED
|
@@ -65,6 +65,9 @@ export async function setupRoutes(app) {
|
|
|
65
65
|
const root = path.resolve(app.maxserver.routesDir || "src");
|
|
66
66
|
const files = walk(root);
|
|
67
67
|
|
|
68
|
+
/*
|
|
69
|
+
// Old one which only graps default exports
|
|
70
|
+
|
|
68
71
|
// 1. Pass One: Register Global Schemas (Lonely .schema.js files)
|
|
69
72
|
for (const file of files) {
|
|
70
73
|
if (file.endsWith(".schema.js")) {
|
|
@@ -76,6 +79,20 @@ export async function setupRoutes(app) {
|
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
}
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
// 1. Pass One: Register Global Schemas (Lonely .schema.js files)
|
|
86
|
+
for (const file of files) {
|
|
87
|
+
// Only process if no matching handler file exists
|
|
88
|
+
if (file.endsWith(".schema.js") && !fs.existsSync(file.replace(".schema.js", ".js"))) {
|
|
89
|
+
const mod = await import(pathToFileURL(file).href);
|
|
90
|
+
|
|
91
|
+
// Register default export + all named exports if they have an $id
|
|
92
|
+
for (const schema of Object.values(mod))
|
|
93
|
+
if (schema?.$id) app.addSchema(schema);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
79
96
|
|
|
80
97
|
// 2. Pass Two: Register Routes
|
|
81
98
|
const seen = new Map();
|