silgi 0.41.6 → 0.41.8
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 +27 -9
- 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
|
@@ -578,7 +578,15 @@ function getUrlPrefix(path, method) {
|
|
|
578
578
|
|
|
579
579
|
async function orchestrate(route, event, _input) {
|
|
580
580
|
const silgiCtx = useSilgi();
|
|
581
|
-
const silgiURL = getUrlPrefix(route.route || event.req.url, route.method)
|
|
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
|
+
};
|
|
582
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);
|
|
@@ -597,7 +605,7 @@ async function orchestrate(route, event, _input) {
|
|
|
597
605
|
}
|
|
598
606
|
};
|
|
599
607
|
try {
|
|
600
|
-
if (!route.service) {
|
|
608
|
+
if (!route.service && !route.graphql) {
|
|
601
609
|
throw createError({
|
|
602
610
|
statusCode: 404,
|
|
603
611
|
statusMessage: "Service not found"
|
|
@@ -632,11 +640,14 @@ async function orchestrate(route, event, _input) {
|
|
|
632
640
|
}
|
|
633
641
|
silgiCtx.shared.$fetch = silgiFetch;
|
|
634
642
|
silgiCtx.shared.silgi = silgiCtx;
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
643
|
+
let result;
|
|
644
|
+
if (!route.graphql) {
|
|
645
|
+
result = await route.service?.setup.handler(
|
|
646
|
+
inputData,
|
|
647
|
+
silgiCtx.shared,
|
|
648
|
+
event
|
|
649
|
+
);
|
|
650
|
+
}
|
|
640
651
|
await silgiCtx.callHook("fetch:after", {
|
|
641
652
|
event,
|
|
642
653
|
url: silgiURL,
|
|
@@ -646,7 +657,7 @@ async function orchestrate(route, event, _input) {
|
|
|
646
657
|
route,
|
|
647
658
|
hookContext
|
|
648
659
|
});
|
|
649
|
-
if (route.service
|
|
660
|
+
if (route.service?.setup.storage && cacheData?.cachedKey) {
|
|
650
661
|
await useSilgiStorage(route.service.setup.storage.base).setItem(
|
|
651
662
|
cacheData.cachedKey,
|
|
652
663
|
result,
|
|
@@ -992,7 +1003,14 @@ async function handler(event, url, input) {
|
|
|
992
1003
|
data: {
|
|
993
1004
|
graphql: true,
|
|
994
1005
|
method: url?.method || event.req.method,
|
|
995
|
-
route: url
|
|
1006
|
+
route: url?.path,
|
|
1007
|
+
service: {
|
|
1008
|
+
setup: {
|
|
1009
|
+
handler: () => {
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
methods: []
|
|
1013
|
+
}
|
|
996
1014
|
},
|
|
997
1015
|
params: {}
|
|
998
1016
|
};
|
package/dist/types/index.d.mts
CHANGED
|
@@ -261,7 +261,7 @@ type ServiceHandlerInput<Input extends StandardSchemaV1 = StandardSchemaV1, Path
|
|
|
261
261
|
* Resolved = false -> handler(input, shared, event, source) // all required
|
|
262
262
|
* Resolved = true -> handler(input, shared?, event?, source?) // only input required
|
|
263
263
|
*/
|
|
264
|
-
type ServiceHandler<Input extends StandardSchemaV1, Output extends StandardSchemaV1, PathParams extends StandardSchemaV1 | never | undefined = never, QueryParams extends StandardSchemaV1 | never | undefined = never, Resolved extends boolean = false, HiddenParameters extends boolean = false> = Resolved extends true ? (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared?: SilgiRuntimeShareds, event?: SilgiEvent) => Promise<InferOutput<Output>> : (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared: SilgiRuntimeShareds, event: SilgiEvent) => Promise<InferOutput<Output
|
|
264
|
+
type ServiceHandler<Input extends StandardSchemaV1, Output extends StandardSchemaV1, PathParams extends StandardSchemaV1 | never | undefined = never, QueryParams extends StandardSchemaV1 | never | undefined = never, Resolved extends boolean = false, HiddenParameters extends boolean = false> = Resolved extends true ? (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared?: SilgiRuntimeShareds, event?: SilgiEvent) => Promise<InferOutput<Output>> | InferOutput<Output> : (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared: SilgiRuntimeShareds, event: SilgiEvent) => Promise<InferOutput<Output>> | InferOutput<Output>;
|
|
265
265
|
/**
|
|
266
266
|
* Servis setup tipi
|
|
267
267
|
*/
|