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.
@@ -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.13";
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
  }
@@ -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
- let result;
653
- if (!isGraphQL) {
654
- result = await route.service?.setup.handler?.(
655
- inputData,
656
- silgiCtx.shared,
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
- 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);
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
- 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);
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
  }
@@ -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.13",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {