silgi 0.41.14 → 0.41.16
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/dist/cli/index.mjs +1 -1
- package/dist/core/index.mjs +17 -8
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.mjs
CHANGED
|
@@ -298,13 +298,6 @@ async function createSilgi(config) {
|
|
|
298
298
|
silgi.router = createRouter();
|
|
299
299
|
}
|
|
300
300
|
for (const [route, object] of Object.entries(silgi.services)) {
|
|
301
|
-
const routeParts = route.split("/").filter(Boolean);
|
|
302
|
-
if (routeParts.length > 0) {
|
|
303
|
-
const prefix = `/${routeParts[0]}`;
|
|
304
|
-
if (!silgi.routerPrefixs.includes(prefix)) {
|
|
305
|
-
silgi.routerPrefixs.push(prefix);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
301
|
const methods = object.methods?.length ? object.methods : ["ALL"];
|
|
309
302
|
if (methods.includes("GRAPHQL")) {
|
|
310
303
|
addRoute(silgi.router, "GRAPHQL", route, {
|
|
@@ -313,6 +306,14 @@ async function createSilgi(config) {
|
|
|
313
306
|
service: object
|
|
314
307
|
});
|
|
315
308
|
continue;
|
|
309
|
+
} else {
|
|
310
|
+
const routeParts = route.split("/").filter(Boolean);
|
|
311
|
+
if (routeParts.length > 0) {
|
|
312
|
+
const prefix = `/${routeParts[0]}`;
|
|
313
|
+
if (!silgi.routerPrefixs.includes(prefix)) {
|
|
314
|
+
silgi.routerPrefixs.push(prefix);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
316
317
|
}
|
|
317
318
|
for (const method of methods) {
|
|
318
319
|
const globalMethod = method === "ALL" ? "" : method.toUpperCase();
|
|
@@ -344,6 +345,14 @@ async function createSilgi(config) {
|
|
|
344
345
|
continue;
|
|
345
346
|
}
|
|
346
347
|
const methods = routeObject.methods?.length ? routeObject.methods : ["ALL"];
|
|
348
|
+
if (methods.includes("GRAPHQL")) {
|
|
349
|
+
addRoute(silgi._middlewareRouter, "GRAPHQL", _route, {
|
|
350
|
+
method: "GRAPHQL",
|
|
351
|
+
route: _route,
|
|
352
|
+
middleware: routeObject.setup
|
|
353
|
+
});
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
347
356
|
for (const method of methods) {
|
|
348
357
|
const globalMethod = method === "ALL" ? "" : method.toUpperCase();
|
|
349
358
|
addRoute(silgi._middlewareRouter, globalMethod, _route, {
|
|
@@ -958,7 +967,7 @@ async function middleware(event, url) {
|
|
|
958
967
|
}
|
|
959
968
|
const _mRouter = silgiContext._middlewareRouter;
|
|
960
969
|
if (_mRouter) {
|
|
961
|
-
const matches = findAllRoutes(_mRouter, event.req.method, pathname);
|
|
970
|
+
const matches = findAllRoutes(_mRouter, url?.method || event.req.method, pathname);
|
|
962
971
|
if (matches.length > 0) {
|
|
963
972
|
_chain = _chain || Promise.resolve();
|
|
964
973
|
for (const match of matches) {
|