silgi 0.41.11 → 0.41.12
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 +14 -18
- 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
|
}
|
|
@@ -932,11 +934,8 @@ async function middleware(event, url) {
|
|
|
932
934
|
if (_previous !== void 0 && _previous !== kNotFound) {
|
|
933
935
|
return _previous;
|
|
934
936
|
}
|
|
935
|
-
let
|
|
936
|
-
|
|
937
|
-
allowedMethods = [allowedMethods];
|
|
938
|
-
}
|
|
939
|
-
const methodIsAllowed = allowedMethods.length === 0 || allowedMethods.includes("ALL") || allowedMethods.includes(event.req.method);
|
|
937
|
+
let allowedMethod = m.method ?? "";
|
|
938
|
+
const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method;
|
|
940
939
|
if (!methodIsAllowed) {
|
|
941
940
|
return;
|
|
942
941
|
}
|
|
@@ -970,11 +969,8 @@ async function middleware(event, url) {
|
|
|
970
969
|
if (_previous !== void 0 && _previous !== kNotFound) {
|
|
971
970
|
return _previous;
|
|
972
971
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
allowedMethods = [allowedMethods];
|
|
976
|
-
}
|
|
977
|
-
const methodIsAllowed = allowedMethods.length === 0 || allowedMethods.includes("ALL") || allowedMethods.includes(event.req.method);
|
|
972
|
+
const allowedMethod = match.data.method ?? "";
|
|
973
|
+
const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method;
|
|
978
974
|
if (!methodIsAllowed || !match.data.middleware) {
|
|
979
975
|
return;
|
|
980
976
|
}
|
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
|
}
|