@dnax/core 0.30.0 → 0.30.2

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/config/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { cors } from "hono/cors";
2
2
  import { Config } from "./../types/index";
3
3
  import type { Config } from "../types";
4
-
4
+ import fs from "fs-extra";
5
5
  import { systemCache } from "../lib/bento";
6
6
  import { Glob } from "bun";
7
7
  import path from "path";
@@ -58,6 +58,7 @@ async function setCfg(config: Config) {
58
58
  await systemCache.set({
59
59
  key: ".jwt.json",
60
60
  value: jwtSecret,
61
+ ttl: "2y",
61
62
  });
62
63
  }
63
64
  Cfg.server.jwt.secret = jwtSecret;
@@ -631,6 +631,19 @@ class useRest {
631
631
 
632
632
  result.docs = toJson(result.docs);
633
633
 
634
+ if (options?.withMeta) {
635
+ meta.count = await this.#tenant.database.db
636
+ ?.collection(collection)
637
+ .countDocuments({
638
+ ...(params?.$match || {}),
639
+ })
640
+ .then((e) => e || 0)
641
+ .catch((err) => 0);
642
+ meta.total = await this.#tenant.database.db
643
+ ?.collection(collection)
644
+ .estimatedDocumentCount();
645
+ }
646
+
634
647
  if (col?.hooks?.afterFind && useHook) {
635
648
  await col.hooks.afterFind({
636
649
  sharedData: sharedData,
@@ -638,6 +651,7 @@ class useRest {
638
651
  io: Cfg.io,
639
652
  driver: "mongodb",
640
653
  action: "find",
654
+ meta: meta,
641
655
  count: result?.docs?.length || 0,
642
656
  params: params,
643
657
  session: sessionStorage(),
@@ -656,17 +670,6 @@ class useRest {
656
670
  }
657
671
 
658
672
  if (options?.withMeta) {
659
- meta.count = await this.#tenant.database.db
660
- ?.collection(collection)
661
- .countDocuments({
662
- ...(params?.$match || {}),
663
- })
664
- .then((e) => e || 0)
665
- .catch((err) => 0);
666
- meta.total = await this.#tenant.database.db
667
- ?.collection(collection)
668
- .estimatedDocumentCount();
669
-
670
673
  return resolve({
671
674
  data: resultDocs,
672
675
  meta: meta,
@@ -21,6 +21,7 @@ if (!fs?.existsSync(path.resolve(cacheDirectoryData + "bentocache"))) {
21
21
 
22
22
  const systemCache = new BentoCache({
23
23
  default: "systemCache",
24
+
24
25
  stores: {
25
26
  systemCache: bentostore().useL2Layer(
26
27
  fileDriver({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.30.0",
3
+ "version": "0.30.2",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
package/types/index.ts CHANGED
@@ -200,6 +200,7 @@ export type hooksCtx = (ctx: {
200
200
  sharedData?: any;
201
201
  action?: Actions;
202
202
  c?: Context;
203
+ meta?: { total: number; count: number; [key: string]: any };
203
204
  rest: InstanceType<typeof useRest>;
204
205
  session?: sessionCtx;
205
206
  io: socketIoType;