silgi 0.37.7 → 0.37.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/build.mjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/core/index.mjs +11 -7
- package/dist/types/index.d.mts +3 -1
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -700,7 +700,7 @@ async function verifyDirectoryCaseSensitivity(directoryPath, rootDirectory) {
|
|
|
700
700
|
} catch {
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
|
-
async function extractExportEntitiesFromFile(absoluteFilePath, functionExportNames = ["createSchema", "createService", "createRoute"], interfaceExtendsNames = ["ExtendShared", "ExtendContext"]) {
|
|
703
|
+
async function extractExportEntitiesFromFile(absoluteFilePath, functionExportNames = ["createSchema", "createService", "createRoute", "createShared"], interfaceExtendsNames = ["ExtendShared", "ExtendContext"]) {
|
|
704
704
|
const exportEntities = [];
|
|
705
705
|
const fileContent = await readFile(absoluteFilePath, "utf-8");
|
|
706
706
|
const parsed = await parseAsync(absoluteFilePath, fileContent);
|
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.mjs
CHANGED
|
@@ -534,22 +534,24 @@ async function orchestrate(route, event) {
|
|
|
534
534
|
const silgiCtx = useSilgi();
|
|
535
535
|
const silgiURL = getUrlPrefix(route.route, event.req.method);
|
|
536
536
|
const input = await parseRequestInput(event.req);
|
|
537
|
+
const hookContext = { earlyReturnValue: false };
|
|
537
538
|
try {
|
|
538
539
|
const routerParams = getRouterParams(event);
|
|
539
540
|
const queryParams = getQuery(event);
|
|
540
541
|
const service = route.service;
|
|
541
|
-
const earlyReturnValue = false;
|
|
542
542
|
const cachePromise = cacheExecute(input, route, silgiURL, event);
|
|
543
543
|
const beforeHookPromise = silgiCtx.callHook("fetch:before", {
|
|
544
544
|
url: silgiURL,
|
|
545
545
|
input,
|
|
546
546
|
event,
|
|
547
547
|
route,
|
|
548
|
-
|
|
548
|
+
hookContext
|
|
549
549
|
});
|
|
550
550
|
const cacheData = await cachePromise;
|
|
551
551
|
await beforeHookPromise;
|
|
552
|
-
if (earlyReturnValue !== false)
|
|
552
|
+
if (hookContext.earlyReturnValue !== false) {
|
|
553
|
+
return hookContext.earlyReturnValue;
|
|
554
|
+
}
|
|
553
555
|
if (cacheData?.success) {
|
|
554
556
|
await silgiCtx.callHook("fetch:after", {
|
|
555
557
|
event,
|
|
@@ -559,7 +561,8 @@ async function orchestrate(route, event) {
|
|
|
559
561
|
success: true,
|
|
560
562
|
cached: true,
|
|
561
563
|
// modules: setup.modules,
|
|
562
|
-
route
|
|
564
|
+
route,
|
|
565
|
+
hookContext
|
|
563
566
|
});
|
|
564
567
|
return cacheData.data;
|
|
565
568
|
}
|
|
@@ -583,8 +586,8 @@ async function orchestrate(route, event) {
|
|
|
583
586
|
input,
|
|
584
587
|
result,
|
|
585
588
|
success: true,
|
|
586
|
-
|
|
587
|
-
|
|
589
|
+
route,
|
|
590
|
+
hookContext
|
|
588
591
|
});
|
|
589
592
|
if (service.storage && cacheData?.cachedKey) {
|
|
590
593
|
await useSilgiStorage(service.storage.base).setItem(
|
|
@@ -601,7 +604,8 @@ async function orchestrate(route, event) {
|
|
|
601
604
|
input,
|
|
602
605
|
error: err instanceof Error ? err : new Error(String(err)),
|
|
603
606
|
url: silgiURL,
|
|
604
|
-
route
|
|
607
|
+
route,
|
|
608
|
+
hookContext
|
|
605
609
|
});
|
|
606
610
|
silgiCtx.captureError(
|
|
607
611
|
silgiCtx,
|
package/dist/types/index.d.mts
CHANGED
|
@@ -826,7 +826,9 @@ type ModuleHookContext = Readonly<{
|
|
|
826
826
|
success?: boolean;
|
|
827
827
|
cached?: boolean;
|
|
828
828
|
}> & {
|
|
829
|
-
|
|
829
|
+
hookContext: {
|
|
830
|
+
earlyReturnValue: any | false;
|
|
831
|
+
};
|
|
830
832
|
};
|
|
831
833
|
/** The options received. */
|
|
832
834
|
type ModuleOptionsCustom = Record<string, any>;
|