silgi 0.41.8 → 0.41.9
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.d.mts +1 -0
- package/dist/core/index.mjs +13 -18
- package/dist/types/index.d.mts +3 -2
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -170,6 +170,7 @@ declare function createService<Path extends string = string, Input extends Stand
|
|
|
170
170
|
path?: PathParams;
|
|
171
171
|
query?: QueryParams;
|
|
172
172
|
};
|
|
173
|
+
mode: 'graphql';
|
|
173
174
|
setup: ServiceSetup<Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
174
175
|
}): {
|
|
175
176
|
[K in Path]: {
|
package/dist/core/index.mjs
CHANGED
|
@@ -305,6 +305,14 @@ async function createSilgi(config) {
|
|
|
305
305
|
silgi.routerPrefixs.push(prefix);
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
|
+
if (object.mode === "graphql") {
|
|
309
|
+
addRoute(silgi.router, "GRAPHQL", route, {
|
|
310
|
+
method: ["GRAPHQL"],
|
|
311
|
+
route,
|
|
312
|
+
service: object
|
|
313
|
+
});
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
308
316
|
const methods = object.methods?.length ? object.methods : ["ALL"];
|
|
309
317
|
for (const method of methods) {
|
|
310
318
|
const globalMethod = method === "ALL" ? "" : method.toUpperCase();
|
|
@@ -642,7 +650,7 @@ async function orchestrate(route, event, _input) {
|
|
|
642
650
|
silgiCtx.shared.silgi = silgiCtx;
|
|
643
651
|
let result;
|
|
644
652
|
if (!route.graphql) {
|
|
645
|
-
result = await route.service?.setup.handler(
|
|
653
|
+
result = await route.service?.setup.handler?.(
|
|
646
654
|
inputData,
|
|
647
655
|
silgiCtx.shared,
|
|
648
656
|
event
|
|
@@ -692,7 +700,7 @@ async function orchestrate(route, event, _input) {
|
|
|
692
700
|
}
|
|
693
701
|
}
|
|
694
702
|
async function cacheExecute(input, route, silgiURL, event) {
|
|
695
|
-
if (!route.service || !route.service.setup
|
|
703
|
+
if (!route.service || !route.service.setup?.storage)
|
|
696
704
|
return;
|
|
697
705
|
const cacheKey = route.service.setup.storage ? await generateStorageKey({
|
|
698
706
|
url: silgiURL,
|
|
@@ -999,21 +1007,7 @@ async function handler(event, url, input) {
|
|
|
999
1007
|
const data = middleware(event, url);
|
|
1000
1008
|
_chain = data;
|
|
1001
1009
|
if (silgiCtx.router) {
|
|
1002
|
-
const match =
|
|
1003
|
-
data: {
|
|
1004
|
-
graphql: true,
|
|
1005
|
-
method: url?.method || event.req.method,
|
|
1006
|
-
route: url?.path,
|
|
1007
|
-
service: {
|
|
1008
|
-
setup: {
|
|
1009
|
-
handler: () => {
|
|
1010
|
-
}
|
|
1011
|
-
},
|
|
1012
|
-
methods: []
|
|
1013
|
-
}
|
|
1014
|
-
},
|
|
1015
|
-
params: {}
|
|
1016
|
-
};
|
|
1010
|
+
const match = findRoute(silgiCtx.router, url?.method || event.req.method, pathname);
|
|
1017
1011
|
if (match) {
|
|
1018
1012
|
if (_chain) {
|
|
1019
1013
|
return _chain.then(async (_previous) => {
|
|
@@ -1088,8 +1082,9 @@ function createService(params) {
|
|
|
1088
1082
|
);
|
|
1089
1083
|
}
|
|
1090
1084
|
const result = {};
|
|
1091
|
-
const { path, setup, methods, input, output, queryParams } = params;
|
|
1085
|
+
const { path, setup, methods, input, output, queryParams, mode } = params;
|
|
1092
1086
|
result[path] = {
|
|
1087
|
+
mode,
|
|
1093
1088
|
setup,
|
|
1094
1089
|
methods,
|
|
1095
1090
|
input,
|
package/dist/types/index.d.mts
CHANGED
|
@@ -266,7 +266,7 @@ type ServiceHandler<Input extends StandardSchemaV1, Output extends StandardSchem
|
|
|
266
266
|
* Servis setup tipi
|
|
267
267
|
*/
|
|
268
268
|
interface ServiceSetup<Input extends StandardSchemaV1 = StandardSchemaV1, Output extends StandardSchemaV1 = StandardSchemaV1, PathParams extends StandardSchemaV1 | never | undefined = never, QueryParams extends StandardSchemaV1 | never | undefined = never, Resolved extends boolean = false, HiddenParameters extends boolean = false> {
|
|
269
|
-
handler
|
|
269
|
+
handler?: ServiceHandler<Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
270
270
|
rules?: RouteRules & {
|
|
271
271
|
readBeforeBody?: boolean;
|
|
272
272
|
};
|
|
@@ -285,6 +285,7 @@ interface ServiceSetup<Input extends StandardSchemaV1 = StandardSchemaV1, Output
|
|
|
285
285
|
interface ResolvedServiceDefinition {
|
|
286
286
|
[routePath: string]: {
|
|
287
287
|
setup: ServiceSetup<any, any, any, any, any, any>;
|
|
288
|
+
mode: 'graphql';
|
|
288
289
|
methods: HTTPMethod[];
|
|
289
290
|
input?: StandardSchemaV1;
|
|
290
291
|
output?: StandardSchemaV1;
|
|
@@ -691,7 +692,7 @@ interface ResolvedSchemaDefinition {
|
|
|
691
692
|
[methodAndRoutePath: string]: BaseMethodSchema;
|
|
692
693
|
}
|
|
693
694
|
|
|
694
|
-
type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'ALL';
|
|
695
|
+
type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'ALL' | 'GRAPHQL';
|
|
695
696
|
type HTTPMethod = SilgiRuntimeMethods extends Record<string, any> ? keyof SilgiRuntimeMethods | StandardHTTPMethod : StandardHTTPMethod;
|
|
696
697
|
interface MetaData extends Record<string, unknown> {
|
|
697
698
|
}
|