silgi 0.41.5 → 0.41.7

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.5";
4
+ const version = "0.41.7";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -576,10 +576,18 @@ function getUrlPrefix(path, method) {
576
576
  };
577
577
  }
578
578
 
579
- async function orchestrate(route, event, _input, graphql) {
579
+ async function orchestrate(route, event, _input) {
580
580
  const silgiCtx = useSilgi();
581
- const silgiURL = getUrlPrefix(route.route || event.req.url, route.method);
582
- const input = _input || (route.service?.setup.rules?.readBeforeBody === false || graphql ? {} : await parseRequestInput(event.req));
581
+ const silgiURL = !route.graphql ? getUrlPrefix(route.route || event.req.url, route.method) : {
582
+ methodName: route.method || "GET",
583
+ namespaceName: "graphql",
584
+ prefixName: "/api",
585
+ path: route.route || "",
586
+ raw: route.route || "",
587
+ pathParams: {},
588
+ queryParams: {}
589
+ };
590
+ const input = _input || (route.service?.setup.rules?.readBeforeBody === false || route.graphql ? {} : await parseRequestInput(event.req));
583
591
  const hookContext = { earlyReturnValue: false };
584
592
  const routerParams = _input ? input.path : getRouterParams(event);
585
593
  const queryParams = _input ? input.query : getQuery(event);
@@ -988,7 +996,14 @@ async function handler(event, url, input) {
988
996
  const data = middleware(event, url);
989
997
  _chain = data;
990
998
  if (silgiCtx.router) {
991
- const match = findRoute(silgiCtx.router, url?.method || event.req.method, pathname);
999
+ const match = !url?.graphql ? findRoute(silgiCtx.router, url?.method || event.req.method, pathname) : {
1000
+ data: {
1001
+ graphql: true,
1002
+ method: url?.method || event.req.method,
1003
+ route: url.path
1004
+ },
1005
+ params: {}
1006
+ };
992
1007
  if (match) {
993
1008
  if (_chain) {
994
1009
  return _chain.then(async (_previous) => {
@@ -997,12 +1012,12 @@ async function handler(event, url, input) {
997
1012
  }
998
1013
  event.context.params = match.params;
999
1014
  event.context.matchedRoute = match.data;
1000
- return orchestrate(match.data, event, input, url?.graphql);
1015
+ return orchestrate(match.data, event, input);
1001
1016
  });
1002
1017
  } else {
1003
1018
  event.context.params = match.params;
1004
1019
  event.context.matchedRoute = match.data;
1005
- return orchestrate(match.data, event, input, url?.graphql);
1020
+ return orchestrate(match.data, event, input);
1006
1021
  }
1007
1022
  }
1008
1023
  }
@@ -697,6 +697,7 @@ interface MetaData extends Record<string, unknown> {
697
697
  }
698
698
  interface SilgiRoute {
699
699
  route?: string;
700
+ graphql?: boolean;
700
701
  method?: HTTPMethod | HTTPMethod[];
701
702
  service?: ResolvedServiceDefinition[string];
702
703
  middleware?: MiddlewareSetup;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.41.5",
4
+ "version": "0.41.7",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {