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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.41.11";
4
+ const version = "0.41.12";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -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: ["GRAPHQL"],
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: [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
- silgi.globalMiddlewares.push({
338
- middleware: routeObject.setup,
339
- method: routeObject.methods?.length ? routeObject.methods : ["ALL"],
340
- route: _route
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: [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 allowedMethods = m.method ?? [];
936
- if (!Array.isArray(allowedMethods)) {
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
- let allowedMethods = match.data.method ?? [];
974
- if (!Array.isArray(allowedMethods)) {
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
  }
@@ -696,7 +696,7 @@ interface MetaData extends Record<string, unknown> {
696
696
  }
697
697
  interface SilgiRoute {
698
698
  route?: string;
699
- method?: HTTPMethod | HTTPMethod[];
699
+ method?: HTTPMethod;
700
700
  service?: ResolvedServiceDefinition[string];
701
701
  middleware?: MiddlewareSetup;
702
702
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.41.11",
4
+ "version": "0.41.12",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {