silgi 0.37.1 → 0.37.3

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.37.1";
4
+ const version = "0.37.3";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -306,7 +306,7 @@ async function createSilgi(config) {
306
306
  addRoute(silgi.router, _method, route, {
307
307
  method: _method,
308
308
  route,
309
- setup: methodObject,
309
+ service: methodObject,
310
310
  schema: schemaWrapper
311
311
  });
312
312
  }
@@ -537,14 +537,17 @@ async function orchestrate(route, event) {
537
537
  try {
538
538
  const routerParams = getRouterParams(event);
539
539
  const queryParams = getQuery(event);
540
- const setup = route.setup;
540
+ const service = route.service;
541
+ const returnNull = false;
541
542
  const cachePromise = cacheExecute(input, route, silgiURL, event);
542
543
  const beforeHookPromise = silgiCtx.callHook("fetch:before", {
543
544
  url: silgiURL,
544
545
  input,
545
546
  event,
546
- route
547
+ route,
548
+ returnNull
547
549
  });
550
+ if (returnNull !== false) ;
548
551
  const cacheData = await cachePromise;
549
552
  await beforeHookPromise;
550
553
  if (cacheData?.success) {
@@ -554,6 +557,7 @@ async function orchestrate(route, event) {
554
557
  input,
555
558
  result: cacheData.data,
556
559
  success: true,
560
+ cached: true,
557
561
  // modules: setup.modules,
558
562
  route
559
563
  });
@@ -561,7 +565,7 @@ async function orchestrate(route, event) {
561
565
  }
562
566
  silgiCtx.shared.$fetch = silgiFetch;
563
567
  silgiCtx.shared.silgi = silgiCtx;
564
- const result = await setup?.handler(
568
+ const result = await service?.handler(
565
569
  {
566
570
  args: input,
567
571
  parameters: {
@@ -582,12 +586,12 @@ async function orchestrate(route, event) {
582
586
  // modules: setup.modules,
583
587
  route
584
588
  });
585
- if (setup.storage && cacheData?.cachedKey) {
586
- await useSilgiStorage(setup.storage.base).setItem(
589
+ if (service.storage && cacheData?.cachedKey) {
590
+ await useSilgiStorage(service.storage.base).setItem(
587
591
  cacheData.cachedKey,
588
592
  result,
589
593
  // Cast to StorageValue if needed
590
- setup.storage.options
594
+ service.storage.options
591
595
  );
592
596
  }
593
597
  return result;
@@ -616,7 +620,7 @@ async function orchestrate(route, event) {
616
620
  }
617
621
  }
618
622
  async function cacheExecute(input, route, silgiURL, event) {
619
- const setup = route.setup;
623
+ const setup = route.service;
620
624
  if (!setup.storage)
621
625
  return;
622
626
  const cacheKey = setup.storage ? await generateStorageKey({
@@ -366,7 +366,6 @@ interface SilgiRuntimeHooks {
366
366
  * @returns Promise
367
367
  */
368
368
  'close': (silgi: Silgi) => HookResult;
369
- 'app:setup:start': (silgi: Silgi) => HookResult;
370
369
  'request:on': (event: SilgiEvent) => HookResult;
371
370
  'fetch:before': (context: ModuleHookContext) => HookResult;
372
371
  'fetch:after': (context: ModuleHookContext) => HookResult;
@@ -661,7 +660,7 @@ type HTTPMethod = SilgiRuntimeMethods extends Record<string, any> ? keyof SilgiR
661
660
  interface SilgiRoute {
662
661
  route: string;
663
662
  method?: HTTPMethod;
664
- setup: ServiceSetup;
663
+ service: ServiceSetup;
665
664
  schema: ResolvedSchemaDefinition;
666
665
  }
667
666
  interface Silgi {
@@ -826,6 +825,7 @@ type ModuleHookContext = Readonly<{
826
825
  error?: Error;
827
826
  success?: boolean;
828
827
  cached?: boolean;
828
+ returnNull?: null | undefined | false;
829
829
  }>;
830
830
  /** The options received. */
831
831
  type ModuleOptionsCustom = Record<string, any>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.37.1",
4
+ "version": "0.37.3",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {