silgi 0.41.11 → 0.41.13
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 +19 -26
- package/dist/types/index.d.mts +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.mjs
CHANGED
|
@@ -308,7 +308,7 @@ async function createSilgi(config) {
|
|
|
308
308
|
const methods = object.methods?.length ? object.methods : ["ALL"];
|
|
309
309
|
if (methods.includes("GRAPHQL")) {
|
|
310
310
|
addRoute(silgi.router, "GRAPHQL", route, {
|
|
311
|
-
method:
|
|
311
|
+
method: "GRAPHQL",
|
|
312
312
|
route,
|
|
313
313
|
service: object
|
|
314
314
|
});
|
|
@@ -317,7 +317,7 @@ async function createSilgi(config) {
|
|
|
317
317
|
for (const method of methods) {
|
|
318
318
|
const globalMethod = method === "ALL" ? "" : method.toUpperCase();
|
|
319
319
|
addRoute(silgi.router, globalMethod, route, {
|
|
320
|
-
method
|
|
320
|
+
method,
|
|
321
321
|
route,
|
|
322
322
|
service: object
|
|
323
323
|
});
|
|
@@ -334,11 +334,13 @@ async function createSilgi(config) {
|
|
|
334
334
|
_route = routeParts.join(":");
|
|
335
335
|
}
|
|
336
336
|
if (_route === "global") {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
337
|
+
for (const method of routeObject.methods?.length ? routeObject.methods : ["ALL"]) {
|
|
338
|
+
silgi.globalMiddlewares.push({
|
|
339
|
+
middleware: routeObject.setup,
|
|
340
|
+
method: method === "ALL" ? "" : method.toUpperCase(),
|
|
341
|
+
route: _route
|
|
342
|
+
});
|
|
343
|
+
}
|
|
342
344
|
continue;
|
|
343
345
|
}
|
|
344
346
|
const methods = routeObject.methods?.length ? routeObject.methods : ["ALL"];
|
|
@@ -346,7 +348,7 @@ async function createSilgi(config) {
|
|
|
346
348
|
const globalMethod = method === "ALL" ? "" : method.toUpperCase();
|
|
347
349
|
addRoute(silgi._middlewareRouter, globalMethod, _route, {
|
|
348
350
|
middleware: routeObject.setup,
|
|
349
|
-
method
|
|
351
|
+
method,
|
|
350
352
|
route: _route
|
|
351
353
|
});
|
|
352
354
|
}
|
|
@@ -649,14 +651,11 @@ async function orchestrate(route, event, _input) {
|
|
|
649
651
|
}
|
|
650
652
|
silgiCtx.shared.$fetch = silgiFetch;
|
|
651
653
|
silgiCtx.shared.silgi = silgiCtx;
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
event
|
|
658
|
-
);
|
|
659
|
-
}
|
|
654
|
+
const result = await route.service?.setup.handler?.(
|
|
655
|
+
inputData,
|
|
656
|
+
silgiCtx.shared,
|
|
657
|
+
event
|
|
658
|
+
);
|
|
660
659
|
await silgiCtx.callHook("fetch:after", {
|
|
661
660
|
event,
|
|
662
661
|
url: silgiURL,
|
|
@@ -932,11 +931,8 @@ async function middleware(event, url) {
|
|
|
932
931
|
if (_previous !== void 0 && _previous !== kNotFound) {
|
|
933
932
|
return _previous;
|
|
934
933
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
allowedMethods = [allowedMethods];
|
|
938
|
-
}
|
|
939
|
-
const methodIsAllowed = allowedMethods.length === 0 || allowedMethods.includes("ALL") || allowedMethods.includes(event.req.method);
|
|
934
|
+
const allowedMethod = m.method ?? "";
|
|
935
|
+
const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method;
|
|
940
936
|
if (!methodIsAllowed) {
|
|
941
937
|
return;
|
|
942
938
|
}
|
|
@@ -970,11 +966,8 @@ async function middleware(event, url) {
|
|
|
970
966
|
if (_previous !== void 0 && _previous !== kNotFound) {
|
|
971
967
|
return _previous;
|
|
972
968
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
allowedMethods = [allowedMethods];
|
|
976
|
-
}
|
|
977
|
-
const methodIsAllowed = allowedMethods.length === 0 || allowedMethods.includes("ALL") || allowedMethods.includes(event.req.method);
|
|
969
|
+
const allowedMethod = match.data.method ?? "";
|
|
970
|
+
const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method;
|
|
978
971
|
if (!methodIsAllowed || !match.data.middleware) {
|
|
979
972
|
return;
|
|
980
973
|
}
|
package/dist/types/index.d.mts
CHANGED
|
@@ -696,7 +696,7 @@ interface MetaData extends Record<string, unknown> {
|
|
|
696
696
|
}
|
|
697
697
|
interface SilgiRoute {
|
|
698
698
|
route?: string;
|
|
699
|
-
method?: HTTPMethod
|
|
699
|
+
method?: HTTPMethod;
|
|
700
700
|
service?: ResolvedServiceDefinition[string];
|
|
701
701
|
middleware?: MiddlewareSetup;
|
|
702
702
|
}
|