zyket 1.1.9 → 1.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
CHANGED
|
@@ -33,7 +33,7 @@ module.exports = class Express extends Service {
|
|
|
33
33
|
|
|
34
34
|
const corsOptions = await this.#loadCorsOrCreateDefault();
|
|
35
35
|
|
|
36
|
-
this.#app.use(cors(corsOptions));
|
|
36
|
+
if(corsOptions) this.#app.use(cors(corsOptions));
|
|
37
37
|
|
|
38
38
|
// Swagger setup
|
|
39
39
|
const swaggerOptions = {
|
|
@@ -171,7 +171,7 @@ module.exports = class Express extends Service {
|
|
|
171
171
|
this.#container.get('logger').info("No CORS configuration found. Creating default config/cors.js");
|
|
172
172
|
fs.mkdirSync(path.join(process.cwd(), "config"), { recursive: true });
|
|
173
173
|
this.#container.get('template-manager').installFile('default/config/cors', corsConfigPath);
|
|
174
|
-
corsOptions =
|
|
174
|
+
corsOptions = false;
|
|
175
175
|
}
|
|
176
176
|
return corsOptions;
|
|
177
177
|
}
|
|
@@ -185,9 +185,21 @@ module.exports = class Express extends Service {
|
|
|
185
185
|
routePath = routePath.replaceAll('index', '/');
|
|
186
186
|
routePath = routePath.replaceAll('//', '/');
|
|
187
187
|
routePath = routePath.replace(/\[([^\]]+)\]/g, ':$1');
|
|
188
|
-
|
|
188
|
+
|
|
189
189
|
return new route(routePath);
|
|
190
190
|
});
|
|
191
|
+
|
|
192
|
+
routes.sort((a, b) => {
|
|
193
|
+
const aSegments = a.path.split('/').filter(Boolean);
|
|
194
|
+
const bSegments = b.path.split('/').filter(Boolean);
|
|
195
|
+
const aDynCount = aSegments.filter(s => s.startsWith(':')).length;
|
|
196
|
+
const bDynCount = bSegments.filter(s => s.startsWith(':')).length;
|
|
197
|
+
if (aDynCount !== bDynCount) return aDynCount - bDynCount;
|
|
198
|
+
const aFirstDyn = aSegments.findIndex(s => s.startsWith(':'));
|
|
199
|
+
const bFirstDyn = bSegments.findIndex(s => s.startsWith(':'));
|
|
200
|
+
return (bFirstDyn === -1 ? Infinity : bFirstDyn) - (aFirstDyn === -1 ? Infinity : aFirstDyn);
|
|
201
|
+
});
|
|
202
|
+
|
|
191
203
|
return routes;
|
|
192
204
|
}
|
|
193
205
|
|