silgi 0.41.13 → 0.41.15
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 +18 -9
- 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, {
|
|
@@ -932,7 +941,7 @@ async function middleware(event, url) {
|
|
|
932
941
|
return _previous;
|
|
933
942
|
}
|
|
934
943
|
const allowedMethod = m.method ?? "";
|
|
935
|
-
const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method;
|
|
944
|
+
const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method || allowedMethod === "GRAPHQL";
|
|
936
945
|
if (!methodIsAllowed) {
|
|
937
946
|
return;
|
|
938
947
|
}
|
|
@@ -967,7 +976,7 @@ async function middleware(event, url) {
|
|
|
967
976
|
return _previous;
|
|
968
977
|
}
|
|
969
978
|
const allowedMethod = match.data.method ?? "";
|
|
970
|
-
const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method;
|
|
979
|
+
const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method || allowedMethod === "GRAPHQL";
|
|
971
980
|
if (!methodIsAllowed || !match.data.middleware) {
|
|
972
981
|
return;
|
|
973
982
|
}
|