@eeplatform/core 1.0.2 → 1.0.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.
package/dist/index.mjs CHANGED
@@ -11368,9 +11368,9 @@ function useVerificationRepo() {
11368
11368
  }
11369
11369
  const namespace_collection = "verifications";
11370
11370
  const collection = db.collection(namespace_collection);
11371
- const { getCache, setCache, delNamespace } = useCache();
11371
+ const { getCache, setCache, delNamespace } = useCache(namespace_collection);
11372
11372
  function delCachedData() {
11373
- delNamespace(namespace_collection).then(() => {
11373
+ delNamespace().then(() => {
11374
11374
  logger.log({
11375
11375
  level: "info",
11376
11376
  message: `Cache namespace cleared for ${namespace_collection}`
@@ -11458,7 +11458,7 @@ function useVerificationRepo() {
11458
11458
  return cached;
11459
11459
  }
11460
11460
  const data = await collection.findOne({ _id });
11461
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
11461
+ setCache(cacheKey, data, 300).then(() => {
11462
11462
  logger.log({
11463
11463
  level: "info",
11464
11464
  message: `Cache set for verification by id: ${cacheKey}`
@@ -11538,7 +11538,7 @@ function useVerificationRepo() {
11538
11538
  ]).toArray();
11539
11539
  const length = await collection.countDocuments(query);
11540
11540
  const data = paginate(items, page, limit, length);
11541
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
11541
+ setCache(cacheKey, data, 600).then(() => {
11542
11542
  logger.log({
11543
11543
  level: "info",
11544
11544
  message: `Cache set for getVerifications: ${cacheKey}`
@@ -11569,7 +11569,7 @@ function useVerificationRepo() {
11569
11569
  return cached;
11570
11570
  }
11571
11571
  const data = await collection.find({ type }).toArray();
11572
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
11572
+ setCache(cacheKey, data, 600).then(() => {
11573
11573
  logger.log({
11574
11574
  level: "info",
11575
11575
  message: `Cache set for verification by type: ${cacheKey}`
@@ -11731,9 +11731,9 @@ function useUserRepo() {
11731
11731
  }
11732
11732
  const namespace_collection = "users";
11733
11733
  const collection = db.collection(namespace_collection);
11734
- const { getCache, setCache, delNamespace } = useCache2();
11734
+ const { getCache, setCache, delNamespace } = useCache2(namespace_collection);
11735
11735
  function delCachedData() {
11736
- delNamespace(namespace_collection).then(() => {
11736
+ delNamespace().then(() => {
11737
11737
  logger2.log({
11738
11738
  level: "info",
11739
11739
  message: `Cache namespace cleared for ${namespace_collection}`
@@ -11795,7 +11795,7 @@ function useUserRepo() {
11795
11795
  }
11796
11796
  const result = await collection.findOne({ email });
11797
11797
  if (result) {
11798
- setCache(cacheKey, result, 300, namespace_collection).then(() => {
11798
+ setCache(cacheKey, result, 300).then(() => {
11799
11799
  logger2.log({
11800
11800
  level: "info",
11801
11801
  message: `Cache set for user by email: ${cacheKey}`
@@ -11825,7 +11825,7 @@ function useUserRepo() {
11825
11825
  }
11826
11826
  const result = await collection.findOne({ referralCode });
11827
11827
  if (result) {
11828
- setCache(cacheKey, result, 300, namespace_collection).then(() => {
11828
+ setCache(cacheKey, result, 300).then(() => {
11829
11829
  logger2.log({
11830
11830
  level: "info",
11831
11831
  message: `Cache set for user by referral code: ${cacheKey}`
@@ -11860,7 +11860,7 @@ function useUserRepo() {
11860
11860
  }
11861
11861
  const result = await collection.findOne({ _id });
11862
11862
  if (result) {
11863
- setCache(cacheKey, result, 300, namespace_collection).then(() => {
11863
+ setCache(cacheKey, result, 300).then(() => {
11864
11864
  logger2.log({
11865
11865
  level: "info",
11866
11866
  message: `Cache set for user by id: ${cacheKey}`
@@ -11934,7 +11934,7 @@ function useUserRepo() {
11934
11934
  ]).toArray();
11935
11935
  const length = await collection.countDocuments(query);
11936
11936
  const data = paginate2(items, page, limit, length);
11937
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
11937
+ setCache(cacheKey, data, 600).then(() => {
11938
11938
  logger2.log({
11939
11939
  level: "info",
11940
11940
  message: `Cache set for getUsers: ${cacheKey}`
@@ -12157,9 +12157,9 @@ function useMemberRepo() {
12157
12157
  }
12158
12158
  const namespace_collection = "members";
12159
12159
  const collection = db.collection(namespace_collection);
12160
- const { getCache, setCache, delNamespace } = useCache3();
12160
+ const { getCache, setCache, delNamespace } = useCache3(namespace_collection);
12161
12161
  function delCachedData() {
12162
- delNamespace(namespace_collection).then(() => {
12162
+ delNamespace().then(() => {
12163
12163
  logger3.log({
12164
12164
  level: "info",
12165
12165
  message: `Cache namespace cleared for ${namespace_collection}`
@@ -12250,7 +12250,7 @@ function useMemberRepo() {
12250
12250
  return cached;
12251
12251
  }
12252
12252
  const data = await collection.findOne({ _id });
12253
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
12253
+ setCache(cacheKey, data, 300).then(() => {
12254
12254
  logger3.log({
12255
12255
  level: "info",
12256
12256
  message: `Cache set for member by id: ${cacheKey}`
@@ -12287,7 +12287,7 @@ function useMemberRepo() {
12287
12287
  return cached;
12288
12288
  }
12289
12289
  const data = await collection.findOne({ user });
12290
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
12290
+ setCache(cacheKey, data, 300).then(() => {
12291
12291
  logger3.log({
12292
12292
  level: "info",
12293
12293
  message: `Cache set for member by user ID: ${cacheKey}`
@@ -12340,7 +12340,7 @@ function useMemberRepo() {
12340
12340
  return cached;
12341
12341
  }
12342
12342
  const data = await collection.findOne(query);
12343
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
12343
+ setCache(cacheKey, data, 300).then(() => {
12344
12344
  logger3.log({
12345
12345
  level: "info",
12346
12346
  message: `Cache set for member by user ID: ${cacheKey}`
@@ -12444,7 +12444,7 @@ function useMemberRepo() {
12444
12444
  ]).toArray();
12445
12445
  const length = await collection.countDocuments(query);
12446
12446
  const data = paginate3(items, page, limit, length);
12447
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
12447
+ setCache(cacheKey, data, 600).then(() => {
12448
12448
  logger3.log({
12449
12449
  level: "info",
12450
12450
  message: `Cache set for getAll members: ${cacheKey}`
@@ -12479,7 +12479,7 @@ function useMemberRepo() {
12479
12479
  return cached;
12480
12480
  }
12481
12481
  const data = await collection.countDocuments({ org, status: "active" });
12482
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
12482
+ setCache(cacheKey, data, 300).then(() => {
12483
12483
  logger3.log({
12484
12484
  level: "info",
12485
12485
  message: `Cache set for countByOrg members: ${cacheKey}`
@@ -12516,7 +12516,7 @@ function useMemberRepo() {
12516
12516
  return cached;
12517
12517
  }
12518
12518
  const data = await collection.countDocuments({ user, status: "active" });
12519
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
12519
+ setCache(cacheKey, data, 300).then(() => {
12520
12520
  logger3.log({
12521
12521
  level: "info",
12522
12522
  message: `Cache set for countByUser members: ${cacheKey}`
@@ -12590,7 +12590,7 @@ function useMemberRepo() {
12590
12590
  ]).toArray();
12591
12591
  const length = await collection.countDocuments(query);
12592
12592
  const data = paginate3(items, page, limit, length);
12593
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
12593
+ setCache(cacheKey, data, 600).then(() => {
12594
12594
  logger3.log({
12595
12595
  level: "info",
12596
12596
  message: `Cache set for getOrgsByMembership members: ${cacheKey}`
@@ -12668,7 +12668,7 @@ function useMemberRepo() {
12668
12668
  ]).toArray();
12669
12669
  const length = await collection.countDocuments(query);
12670
12670
  const data = paginate3(items, page, limit, length);
12671
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
12671
+ setCache(cacheKey, data, 300).then(() => {
12672
12672
  logger3.log({
12673
12673
  level: "info",
12674
12674
  message: `Cache set for getOrgsByUserId members: ${cacheKey}`
@@ -13241,9 +13241,9 @@ function useTokenRepo() {
13241
13241
  }
13242
13242
  const namespace_collection = "tokens";
13243
13243
  const collection = db.collection(namespace_collection);
13244
- const { getCache, setCache, delNamespace } = useCache4();
13244
+ const { getCache, setCache, delNamespace } = useCache4(namespace_collection);
13245
13245
  function delCachedData() {
13246
- delNamespace(namespace_collection).then(() => {
13246
+ delNamespace().then(() => {
13247
13247
  logger5.log({
13248
13248
  level: "info",
13249
13249
  message: `Cache namespace cleared for ${namespace_collection}`
@@ -13282,7 +13282,7 @@ function useTokenRepo() {
13282
13282
  }
13283
13283
  const data = await collection.findOne({ token });
13284
13284
  if (data) {
13285
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
13285
+ setCache(cacheKey, data, 300).then(() => {
13286
13286
  logger5.log({
13287
13287
  level: "info",
13288
13288
  message: `Cache set for token: ${cacheKey}`
@@ -13358,9 +13358,9 @@ function useFileRepo() {
13358
13358
  }
13359
13359
  const namespace_collection = "files";
13360
13360
  const collection = db.collection(namespace_collection);
13361
- const { getCache, setCache, delNamespace } = useCache5();
13361
+ const { getCache, setCache, delNamespace } = useCache5(namespace_collection);
13362
13362
  function delCachedData() {
13363
- delNamespace(namespace_collection).then(() => {
13363
+ delNamespace().then(() => {
13364
13364
  logger6.log({
13365
13365
  level: "info",
13366
13366
  message: `Cache namespace cleared for ${namespace_collection}`
@@ -13408,7 +13408,7 @@ function useFileRepo() {
13408
13408
  return cached;
13409
13409
  }
13410
13410
  const data = await collection.find({ $and: [{ status: "draft" }, { status: null }] }).toArray();
13411
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
13411
+ setCache(cacheKey, data, 300).then(() => {
13412
13412
  logger6.log({
13413
13413
  level: "info",
13414
13414
  message: `Cache set for getAllDraftedFiles: ${cacheKey}`
@@ -13481,6 +13481,16 @@ var isPlainObject = (val) => {
13481
13481
  const prototype3 = getPrototypeOf(val);
13482
13482
  return (prototype3 === null || prototype3 === Object.prototype || Object.getPrototypeOf(prototype3) === null) && !(toStringTag in val) && !(iterator in val);
13483
13483
  };
13484
+ var isEmptyObject = (val) => {
13485
+ if (!isObject(val) || isBuffer(val)) {
13486
+ return false;
13487
+ }
13488
+ try {
13489
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
13490
+ } catch (e) {
13491
+ return false;
13492
+ }
13493
+ };
13484
13494
  var isDate = kindOfTest("Date");
13485
13495
  var isFile = kindOfTest("File");
13486
13496
  var isBlob = kindOfTest("Blob");
@@ -13508,6 +13518,9 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
13508
13518
  fn.call(null, obj[i], i, obj);
13509
13519
  }
13510
13520
  } else {
13521
+ if (isBuffer(obj)) {
13522
+ return;
13523
+ }
13511
13524
  const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
13512
13525
  const len = keys.length;
13513
13526
  let key;
@@ -13518,6 +13531,9 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
13518
13531
  }
13519
13532
  }
13520
13533
  function findKey(obj, key) {
13534
+ if (isBuffer(obj)) {
13535
+ return null;
13536
+ }
13521
13537
  key = key.toLowerCase();
13522
13538
  const keys = Object.keys(obj);
13523
13539
  let i = keys.length;
@@ -13714,6 +13730,9 @@ var toJSONObject = (obj) => {
13714
13730
  if (stack.indexOf(source) >= 0) {
13715
13731
  return;
13716
13732
  }
13733
+ if (isBuffer(source)) {
13734
+ return source;
13735
+ }
13717
13736
  if (!("toJSON" in source)) {
13718
13737
  stack[i] = source;
13719
13738
  const target = isArray(source) ? [] : {};
@@ -13763,6 +13782,7 @@ var utils_default = {
13763
13782
  isBoolean,
13764
13783
  isObject,
13765
13784
  isPlainObject,
13785
+ isEmptyObject,
13766
13786
  isReadableStream,
13767
13787
  isRequest,
13768
13788
  isResponse,
@@ -14207,15 +14227,16 @@ var platform_default = {
14207
14227
 
14208
14228
  // node_modules/axios/lib/helpers/toURLEncodedForm.js
14209
14229
  function toURLEncodedForm(data, options) {
14210
- return toFormData_default(data, new platform_default.classes.URLSearchParams(), Object.assign({
14230
+ return toFormData_default(data, new platform_default.classes.URLSearchParams(), {
14211
14231
  visitor: function(value, key, path, helpers) {
14212
14232
  if (platform_default.isNode && utils_default.isBuffer(value)) {
14213
14233
  this.append(key, value.toString("base64"));
14214
14234
  return false;
14215
14235
  }
14216
14236
  return helpers.defaultVisitor.apply(this, arguments);
14217
- }
14218
- }, options));
14237
+ },
14238
+ ...options
14239
+ });
14219
14240
  }
14220
14241
 
14221
14242
  // node_modules/axios/lib/helpers/formDataToJSON.js
@@ -14728,7 +14749,7 @@ import util2 from "util";
14728
14749
  import zlib from "zlib";
14729
14750
 
14730
14751
  // node_modules/axios/lib/env/data.js
14731
- var VERSION = "1.10.0";
14752
+ var VERSION = "1.11.0";
14732
14753
 
14733
14754
  // node_modules/axios/lib/helpers/parseProtocol.js
14734
14755
  function parseProtocol(url2) {
@@ -15070,7 +15091,7 @@ function throttle(fn, freq) {
15070
15091
  clearTimeout(timer);
15071
15092
  timer = null;
15072
15093
  }
15073
- fn.apply(null, args);
15094
+ fn(...args);
15074
15095
  };
15075
15096
  const throttled = (...args) => {
15076
15097
  const now = Date.now();
@@ -15745,7 +15766,7 @@ function mergeConfig(config1, config2) {
15745
15766
  validateStatus: mergeDirectKeys,
15746
15767
  headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
15747
15768
  };
15748
- utils_default.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
15769
+ utils_default.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
15749
15770
  const merge2 = mergeMap[prop] || mergeDeepProperties;
15750
15771
  const configValue = merge2(config1[prop], config2[prop], prop);
15751
15772
  utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config3[prop] = configValue);
@@ -16459,8 +16480,8 @@ var Axios = class {
16459
16480
  let len;
16460
16481
  if (!synchronousRequestInterceptors) {
16461
16482
  const chain = [dispatchRequest.bind(this), void 0];
16462
- chain.unshift.apply(chain, requestInterceptorChain);
16463
- chain.push.apply(chain, responseInterceptorChain);
16483
+ chain.unshift(...requestInterceptorChain);
16484
+ chain.push(...responseInterceptorChain);
16464
16485
  len = chain.length;
16465
16486
  promise = Promise.resolve(config2);
16466
16487
  while (i < len) {
@@ -17442,9 +17463,9 @@ function useRoleRepo() {
17442
17463
  }
17443
17464
  const namespace_collection = "roles";
17444
17465
  const collection = db.collection(namespace_collection);
17445
- const { getCache, setCache, delNamespace } = useCache6();
17466
+ const { getCache, setCache, delNamespace } = useCache6(namespace_collection);
17446
17467
  function delCachedData() {
17447
- delNamespace(namespace_collection).then(() => {
17468
+ delNamespace().then(() => {
17448
17469
  logger8.log({
17449
17470
  level: "info",
17450
17471
  message: `Cache namespace cleared for ${namespace_collection}`
@@ -17517,7 +17538,7 @@ function useRoleRepo() {
17517
17538
  return cached;
17518
17539
  }
17519
17540
  const data = await collection.findOne({ user: value });
17520
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
17541
+ setCache(cacheKey, data, 300).then(() => {
17521
17542
  logger8.log({
17522
17543
  level: "info",
17523
17544
  message: `Cache set for role by user ID: ${cacheKey}`
@@ -17552,7 +17573,7 @@ function useRoleRepo() {
17552
17573
  return cached;
17553
17574
  }
17554
17575
  const data = await collection.findOne({ _id });
17555
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
17576
+ setCache(cacheKey, data, 300).then(() => {
17556
17577
  logger8.log({
17557
17578
  level: "info",
17558
17579
  message: `Cache set for role by id: ${cacheKey}`
@@ -17585,7 +17606,7 @@ function useRoleRepo() {
17585
17606
  return cached;
17586
17607
  }
17587
17608
  const data = await collection.findOne({ name });
17588
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
17609
+ setCache(cacheKey, data, 300).then(() => {
17589
17610
  logger8.log({
17590
17611
  level: "info",
17591
17612
  message: `Cache set for role by name: ${cacheKey}`
@@ -17659,7 +17680,7 @@ function useRoleRepo() {
17659
17680
  ]).toArray();
17660
17681
  const length = await collection.countDocuments(query);
17661
17682
  const data = paginate4(items, page, limit, length);
17662
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
17683
+ setCache(cacheKey, data, 600).then(() => {
17663
17684
  logger8.log({
17664
17685
  level: "info",
17665
17686
  message: `Cache set for getRoles: ${cacheKey}`
@@ -18373,11 +18394,14 @@ import {
18373
18394
  comparePassword,
18374
18395
  generateToken,
18375
18396
  InternalServerError as InternalServerError11,
18376
- NotFoundError as NotFoundError3
18397
+ NotFoundError as NotFoundError3,
18398
+ useCache as useCache8
18377
18399
  } from "@eeplatform/nodejs-utils";
18378
18400
  import jwt from "jsonwebtoken";
18401
+ import { v4 as uuidv4 } from "uuid";
18379
18402
  function useAuthService() {
18380
18403
  const expiresIn = "1m";
18404
+ const { setCache, delCache } = useCache8("sessions");
18381
18405
  async function login({ email, password } = {}) {
18382
18406
  if (!email) {
18383
18407
  throw new BadRequestError13("Email is required");
@@ -18409,34 +18433,14 @@ function useAuthService() {
18409
18433
  if (!isPasswordValid) {
18410
18434
  throw new BadRequestError13("Invalid password");
18411
18435
  }
18412
- const metadata = { user: _user._id };
18413
- let refreshToken2;
18414
- try {
18415
- refreshToken2 = generateToken({
18416
- secret: REFRESH_TOKEN_SECRET,
18417
- metadata,
18418
- options: { expiresIn: "7d" }
18419
- });
18420
- } catch (error) {
18421
- throw new BadRequestError13("Error generating refresh token");
18422
- }
18423
- let accessToken;
18424
- try {
18425
- accessToken = generateToken({
18426
- secret: ACCESS_TOKEN_SECRET,
18427
- metadata,
18428
- options: { expiresIn }
18429
- });
18430
- } catch (error) {
18431
- throw new BadRequestError13("Error generating access token");
18432
- }
18433
- const user = _user._id ?? "";
18434
- try {
18435
- await useTokenRepo().createToken({ token: refreshToken2, user });
18436
- } catch (error) {
18437
- throw new BadRequestError13("Error creating refresh token");
18438
- }
18439
- return { accessToken, refreshToken: refreshToken2, id: _user._id };
18436
+ const sid = uuidv4();
18437
+ const cacheKey = `sid:${sid}`;
18438
+ setCache(cacheKey, _user, 14400).then(() => {
18439
+ console.log("Session ID cached successfully");
18440
+ }).catch((error) => {
18441
+ console.error("Error caching session ID:", error);
18442
+ });
18443
+ return { sid, user: _user._id?.toString() ?? "" };
18440
18444
  }
18441
18445
  async function refreshToken(token) {
18442
18446
  let decoded;
@@ -18470,26 +18474,13 @@ function useAuthService() {
18470
18474
  }
18471
18475
  return accessToken;
18472
18476
  }
18473
- async function logout(token) {
18474
- let _token;
18475
- try {
18476
- _token = await useTokenRepo().getToken(token);
18477
- if (!_token) {
18478
- throw new NotFoundError3("Invalid token");
18479
- }
18480
- } catch (error) {
18481
- if (error instanceof AppError5) {
18482
- throw error;
18483
- } else {
18484
- throw new InternalServerError11(`${error}`);
18485
- }
18486
- }
18477
+ async function logout(sid) {
18487
18478
  try {
18488
- await useTokenRepo().deleteToken(token);
18479
+ await delCache(`sid:${sid}`);
18480
+ return "Session deleted successfully";
18489
18481
  } catch (error) {
18490
18482
  throw new InternalServerError11("Error deleting token");
18491
18483
  }
18492
- return "Logged out successfully";
18493
18484
  }
18494
18485
  return {
18495
18486
  login,
@@ -18503,7 +18494,8 @@ import Joi5 from "joi";
18503
18494
  import {
18504
18495
  AppError as AppError6,
18505
18496
  BadRequestError as BadRequestError14,
18506
- InternalServerError as InternalServerError12
18497
+ InternalServerError as InternalServerError12,
18498
+ logger as logger10
18507
18499
  } from "@eeplatform/nodejs-utils";
18508
18500
  function useAuthController() {
18509
18501
  const { signUp: _signUp } = useVerificationService();
@@ -18517,16 +18509,26 @@ function useAuthController() {
18517
18509
  const { error } = validation.validate({ email, password });
18518
18510
  if (error) {
18519
18511
  next(new BadRequestError14(error.message));
18512
+ return;
18520
18513
  }
18521
18514
  try {
18522
- const token = await useAuthService().login({ email, password });
18523
- res.json(token);
18515
+ const session = await useAuthService().login({
18516
+ email,
18517
+ password
18518
+ });
18519
+ res.json(session);
18524
18520
  } catch (error2) {
18521
+ logger10.log({
18522
+ level: "error",
18523
+ message: `Error during login: ${error2.message}`
18524
+ });
18525
+ console.log(`Error during login: ${error2}`);
18525
18526
  if (error2 instanceof AppError6) {
18526
18527
  next(error2);
18527
18528
  } else {
18528
18529
  next(new InternalServerError12("An unexpected error occurred"));
18529
18530
  }
18531
+ return;
18530
18532
  }
18531
18533
  }
18532
18534
  async function refreshToken(req, res, next) {
@@ -18547,13 +18549,13 @@ function useAuthController() {
18547
18549
  }
18548
18550
  }
18549
18551
  async function logout(req, res, next) {
18550
- const token = req.params.id || "";
18551
- if (!token) {
18552
- next(new BadRequestError14("Token is required"));
18552
+ const sid = req.headers["authorization"] ?? "";
18553
+ if (!sid) {
18554
+ next(new BadRequestError14("Session ID is required"));
18553
18555
  return;
18554
18556
  }
18555
18557
  try {
18556
- await useAuthService().logout(token);
18558
+ await useAuthService().logout(sid);
18557
18559
  res.json({ message: "Logged out successfully" });
18558
18560
  } catch (error) {
18559
18561
  if (error instanceof AppError6) {
@@ -18628,7 +18630,7 @@ function useAuthController() {
18628
18630
  }
18629
18631
 
18630
18632
  // src/services/file.service.ts
18631
- import { logger as logger10, useS3 as useS32, useAtlas as useAtlas9 } from "@eeplatform/nodejs-utils";
18633
+ import { logger as logger11, useS3 as useS32, useAtlas as useAtlas9 } from "@eeplatform/nodejs-utils";
18632
18634
  import cron from "node-cron";
18633
18635
  function useFileService() {
18634
18636
  const {
@@ -18689,12 +18691,12 @@ function useFileService() {
18689
18691
  const file = files[index];
18690
18692
  try {
18691
18693
  await deleteFile(file._id.toString());
18692
- await logger10.log({
18694
+ await logger11.log({
18693
18695
  level: "info",
18694
18696
  message: "Successfully deleted draft files."
18695
18697
  });
18696
18698
  } catch (error) {
18697
- logger10.log({
18699
+ logger11.log({
18698
18700
  level: "info",
18699
18701
  message: "Successfully deleted draft files."
18700
18702
  });
@@ -18948,11 +18950,11 @@ import { ObjectId as ObjectId16 } from "mongodb";
18948
18950
  import {
18949
18951
  BadRequestError as BadRequestError17,
18950
18952
  InternalServerError as InternalServerError15,
18951
- logger as logger11,
18953
+ logger as logger12,
18952
18954
  makeCacheKey as makeCacheKey8,
18953
18955
  paginate as paginate5,
18954
18956
  useAtlas as useAtlas10,
18955
- useCache as useCache8
18957
+ useCache as useCache9
18956
18958
  } from "@eeplatform/nodejs-utils";
18957
18959
  function useEntityRepo() {
18958
18960
  const db = useAtlas10.getDb();
@@ -18961,15 +18963,15 @@ function useEntityRepo() {
18961
18963
  }
18962
18964
  const namespace_collection = "entities";
18963
18965
  const collection = db.collection(namespace_collection);
18964
- const { getCache, setCache, delNamespace } = useCache8();
18966
+ const { getCache, setCache, delNamespace } = useCache9(namespace_collection);
18965
18967
  function delCachedData() {
18966
- delNamespace(namespace_collection).then(() => {
18967
- logger11.log({
18968
+ delNamespace().then(() => {
18969
+ logger12.log({
18968
18970
  level: "info",
18969
18971
  message: `Cache namespace cleared for ${namespace_collection}`
18970
18972
  });
18971
18973
  }).catch((err) => {
18972
- logger11.log({
18974
+ logger12.log({
18973
18975
  level: "error",
18974
18976
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
18975
18977
  });
@@ -18999,7 +19001,7 @@ function useEntityRepo() {
18999
19001
  delCachedData();
19000
19002
  return res.insertedId.toString();
19001
19003
  } catch (error) {
19002
- logger11.log({ level: "error", message: `${error}` });
19004
+ logger12.log({ level: "error", message: `${error}` });
19003
19005
  const isDuplicated = error.message.includes("duplicate");
19004
19006
  if (isDuplicated) {
19005
19007
  throw new BadRequestError17("Entity name already exists.");
@@ -19029,7 +19031,7 @@ function useEntityRepo() {
19029
19031
  try {
19030
19032
  const cached = await getCache(cacheKey);
19031
19033
  if (cached) {
19032
- logger11.log({
19034
+ logger12.log({
19033
19035
  level: "info",
19034
19036
  message: `Cache hit for getEntities: ${cacheKey}`
19035
19037
  });
@@ -19043,20 +19045,20 @@ function useEntityRepo() {
19043
19045
  ]).toArray();
19044
19046
  const length = await collection.countDocuments(query);
19045
19047
  const data = paginate5(items, page, limit, length);
19046
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
19047
- logger11.log({
19048
+ setCache(cacheKey, data, 600).then(() => {
19049
+ logger12.log({
19048
19050
  level: "info",
19049
19051
  message: `Cache set for getEntities: ${cacheKey}`
19050
19052
  });
19051
19053
  }).catch((err) => {
19052
- logger11.log({
19054
+ logger12.log({
19053
19055
  level: "error",
19054
19056
  message: `Failed to set cache for getEntities: ${err.message}`
19055
19057
  });
19056
19058
  });
19057
19059
  return data;
19058
19060
  } catch (error) {
19059
- logger11.log({ level: "error", message: `${error}` });
19061
+ logger12.log({ level: "error", message: `${error}` });
19060
19062
  throw error;
19061
19063
  }
19062
19064
  }
@@ -19312,11 +19314,11 @@ function MSubscription(value) {
19312
19314
  // src/repositories/subscription.repository.ts
19313
19315
  import {
19314
19316
  BadRequestError as BadRequestError20,
19315
- logger as logger12,
19317
+ logger as logger13,
19316
19318
  makeCacheKey as makeCacheKey9,
19317
19319
  paginate as paginate6,
19318
19320
  useAtlas as useAtlas11,
19319
- useCache as useCache9
19321
+ useCache as useCache10
19320
19322
  } from "@eeplatform/nodejs-utils";
19321
19323
  import { ObjectId as ObjectId18 } from "mongodb";
19322
19324
  import Joi10 from "joi";
@@ -19327,15 +19329,15 @@ function useSubscriptionRepo() {
19327
19329
  }
19328
19330
  const namespace_collection = "subscriptions";
19329
19331
  const collection = db.collection(namespace_collection);
19330
- const { getCache, setCache, delNamespace } = useCache9();
19332
+ const { getCache, setCache, delNamespace } = useCache10(namespace_collection);
19331
19333
  function delCachedData() {
19332
- delNamespace(namespace_collection).then(() => {
19333
- logger12.log({
19334
+ delNamespace().then(() => {
19335
+ logger13.log({
19334
19336
  level: "info",
19335
19337
  message: `Cache namespace cleared for ${namespace_collection}`
19336
19338
  });
19337
19339
  }).catch((err) => {
19338
- logger12.log({
19340
+ logger13.log({
19339
19341
  level: "error",
19340
19342
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
19341
19343
  });
@@ -19387,7 +19389,7 @@ function useSubscriptionRepo() {
19387
19389
  try {
19388
19390
  const cached = await getCache(cacheKey);
19389
19391
  if (cached) {
19390
- logger12.log({
19392
+ logger13.log({
19391
19393
  level: "info",
19392
19394
  message: `Cache hit for getById subscription: ${cacheKey}`
19393
19395
  });
@@ -19395,13 +19397,13 @@ function useSubscriptionRepo() {
19395
19397
  }
19396
19398
  const data = await collection.findOne({ _id });
19397
19399
  if (data) {
19398
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
19399
- logger12.log({
19400
+ setCache(cacheKey, data, 300).then(() => {
19401
+ logger13.log({
19400
19402
  level: "info",
19401
19403
  message: `Cache set for subscription by ID: ${cacheKey}`
19402
19404
  });
19403
19405
  }).catch((err) => {
19404
- logger12.log({
19406
+ logger13.log({
19405
19407
  level: "error",
19406
19408
  message: `Failed to set cache for subscription by ID: ${err.message}`
19407
19409
  });
@@ -19422,7 +19424,7 @@ function useSubscriptionRepo() {
19422
19424
  try {
19423
19425
  const cached = await getCache(cacheKey);
19424
19426
  if (cached) {
19425
- logger12.log({
19427
+ logger13.log({
19426
19428
  level: "info",
19427
19429
  message: `Cache hit for getByUserId subscription: ${cacheKey}`
19428
19430
  });
@@ -19430,13 +19432,13 @@ function useSubscriptionRepo() {
19430
19432
  }
19431
19433
  const data = await collection.findOne({ user });
19432
19434
  if (data) {
19433
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
19434
- logger12.log({
19435
+ setCache(cacheKey, data, 300).then(() => {
19436
+ logger13.log({
19435
19437
  level: "info",
19436
19438
  message: `Cache set for subscription by user ID: ${cacheKey}`
19437
19439
  });
19438
19440
  }).catch((err) => {
19439
- logger12.log({
19441
+ logger13.log({
19440
19442
  level: "error",
19441
19443
  message: `Failed to set cache for subscription by user ID: ${err.message}`
19442
19444
  });
@@ -19482,7 +19484,7 @@ function useSubscriptionRepo() {
19482
19484
  try {
19483
19485
  const cached = await getCache(cacheKey);
19484
19486
  if (cached) {
19485
- logger12.log({
19487
+ logger13.log({
19486
19488
  level: "info",
19487
19489
  message: `Cache hit for getBySubscriptionId: ${cacheKey}`
19488
19490
  });
@@ -19490,13 +19492,13 @@ function useSubscriptionRepo() {
19490
19492
  }
19491
19493
  const data = await collection.findOne({ subscriptionId });
19492
19494
  if (data) {
19493
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
19494
- logger12.log({
19495
+ setCache(cacheKey, data, 300).then(() => {
19496
+ logger13.log({
19495
19497
  level: "info",
19496
19498
  message: `Cache set for subscription by subscription ID: ${cacheKey}`
19497
19499
  });
19498
19500
  }).catch((err) => {
19499
- logger12.log({
19501
+ logger13.log({
19500
19502
  level: "error",
19501
19503
  message: `Failed to set cache for subscription by subscription ID: ${err.message}`
19502
19504
  });
@@ -19532,7 +19534,7 @@ function useSubscriptionRepo() {
19532
19534
  try {
19533
19535
  const cached = await getCache(cacheKey);
19534
19536
  if (cached) {
19535
- logger12.log({
19537
+ logger13.log({
19536
19538
  level: "info",
19537
19539
  message: `Cache hit for getSubscriptions: ${cacheKey}`
19538
19540
  });
@@ -19546,20 +19548,20 @@ function useSubscriptionRepo() {
19546
19548
  ]).toArray();
19547
19549
  const length = await collection.countDocuments(query);
19548
19550
  const data = paginate6(items, page, limit, length);
19549
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
19550
- logger12.log({
19551
+ setCache(cacheKey, data, 600).then(() => {
19552
+ logger13.log({
19551
19553
  level: "info",
19552
19554
  message: `Cache set for getSubscriptions: ${cacheKey}`
19553
19555
  });
19554
19556
  }).catch((err) => {
19555
- logger12.log({
19557
+ logger13.log({
19556
19558
  level: "error",
19557
19559
  message: `Failed to set cache for getSubscriptions: ${err.message}`
19558
19560
  });
19559
19561
  });
19560
19562
  return data;
19561
19563
  } catch (error) {
19562
- logger12.log({ level: "error", message: `${error}` });
19564
+ logger13.log({ level: "error", message: `${error}` });
19563
19565
  throw error;
19564
19566
  }
19565
19567
  }
@@ -19706,10 +19708,10 @@ function useSubscriptionRepo() {
19706
19708
  },
19707
19709
  { session }
19708
19710
  );
19709
- logger12.info(`${res.modifiedCount} subscription updated.`);
19711
+ logger13.info(`${res.modifiedCount} subscription updated.`);
19710
19712
  return "Successfully updated subscription.";
19711
19713
  } catch (error2) {
19712
- logger12.error(`${error2}`);
19714
+ logger13.error(`${error2}`);
19713
19715
  throw new BadRequestError20("Failed to update subscription.");
19714
19716
  }
19715
19717
  }
@@ -19961,7 +19963,7 @@ function useSubscriptionRepo() {
19961
19963
  import {
19962
19964
  AppError as AppError9,
19963
19965
  BadRequestError as BadRequestError33,
19964
- logger as logger20,
19966
+ logger as logger21,
19965
19967
  useAtlas as useAtlas19
19966
19968
  } from "@eeplatform/nodejs-utils";
19967
19969
 
@@ -19970,11 +19972,11 @@ import {
19970
19972
  AppError as AppError8,
19971
19973
  BadRequestError as BadRequestError22,
19972
19974
  InternalServerError as InternalServerError16,
19973
- logger as logger13,
19975
+ logger as logger14,
19974
19976
  makeCacheKey as makeCacheKey10,
19975
19977
  paginate as paginate7,
19976
19978
  useAtlas as useAtlas12,
19977
- useCache as useCache10
19979
+ useCache as useCache11
19978
19980
  } from "@eeplatform/nodejs-utils";
19979
19981
 
19980
19982
  // src/models/organization.model.ts
@@ -20029,7 +20031,7 @@ function useOrgRepo() {
20029
20031
  }
20030
20032
  const namespace_collection = "organizations";
20031
20033
  const collection = db.collection(namespace_collection);
20032
- const { getCache, setCache, delNamespace } = useCache10();
20034
+ const { getCache, setCache, delNamespace } = useCache11(namespace_collection);
20033
20035
  async function createIndex() {
20034
20036
  try {
20035
20037
  await collection.createIndex([
@@ -20064,13 +20066,13 @@ function useOrgRepo() {
20064
20066
  }
20065
20067
  }
20066
20068
  function delCachedData() {
20067
- delNamespace(namespace_collection).then(() => {
20068
- logger13.log({
20069
+ delNamespace().then(() => {
20070
+ logger14.log({
20069
20071
  level: "info",
20070
20072
  message: `Cache namespace cleared for ${namespace_collection}`
20071
20073
  });
20072
20074
  }).catch((err) => {
20073
- logger13.log({
20075
+ logger14.log({
20074
20076
  level: "error",
20075
20077
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
20076
20078
  });
@@ -20083,7 +20085,7 @@ function useOrgRepo() {
20083
20085
  delCachedData();
20084
20086
  return res.insertedId;
20085
20087
  } catch (error) {
20086
- logger13.log({
20088
+ logger14.log({
20087
20089
  level: "error",
20088
20090
  message: error.message
20089
20091
  });
@@ -20118,14 +20120,14 @@ function useOrgRepo() {
20118
20120
  sort: JSON.stringify(sort),
20119
20121
  status
20120
20122
  });
20121
- logger13.log({
20123
+ logger14.log({
20122
20124
  level: "info",
20123
20125
  message: `Cache key for getAll organizations: ${cacheKey}`
20124
20126
  });
20125
20127
  try {
20126
20128
  const cached = await getCache(cacheKey);
20127
20129
  if (cached) {
20128
- logger13.log({
20130
+ logger14.log({
20129
20131
  level: "info",
20130
20132
  message: `Cache hit for getAll organizations: ${cacheKey}`
20131
20133
  });
@@ -20148,20 +20150,20 @@ function useOrgRepo() {
20148
20150
  ]).toArray();
20149
20151
  const length = await collection.countDocuments(query);
20150
20152
  const data = paginate7(items, page, limit, length);
20151
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
20152
- logger13.log({
20153
+ setCache(cacheKey, data, 600).then(() => {
20154
+ logger14.log({
20153
20155
  level: "info",
20154
20156
  message: `Cache set for getAll organizations: ${cacheKey}`
20155
20157
  });
20156
20158
  }).catch((err) => {
20157
- logger13.log({
20159
+ logger14.log({
20158
20160
  level: "error",
20159
20161
  message: `Failed to set cache for getAll organizations: ${err.message}`
20160
20162
  });
20161
20163
  });
20162
20164
  return data;
20163
20165
  } catch (error) {
20164
- logger13.log({ level: "error", message: `${error}` });
20166
+ logger14.log({ level: "error", message: `${error}` });
20165
20167
  throw error;
20166
20168
  }
20167
20169
  }
@@ -20175,7 +20177,7 @@ function useOrgRepo() {
20175
20177
  try {
20176
20178
  const cached = await getCache(cacheKey);
20177
20179
  if (cached) {
20178
- logger13.log({
20180
+ logger14.log({
20179
20181
  level: "info",
20180
20182
  message: `Cache hit for getById organization: ${cacheKey}`
20181
20183
  });
@@ -20185,13 +20187,13 @@ function useOrgRepo() {
20185
20187
  if (!result) {
20186
20188
  throw new BadRequestError22("Organization not found.");
20187
20189
  }
20188
- setCache(cacheKey, result, 300, namespace_collection).then(() => {
20189
- logger13.log({
20190
+ setCache(cacheKey, result, 300).then(() => {
20191
+ logger14.log({
20190
20192
  level: "info",
20191
20193
  message: `Cache set for organization by id: ${cacheKey}`
20192
20194
  });
20193
20195
  }).catch((err) => {
20194
- logger13.log({
20196
+ logger14.log({
20195
20197
  level: "error",
20196
20198
  message: `Failed to set cache for organization by id: ${err.message}`
20197
20199
  });
@@ -20210,7 +20212,7 @@ function useOrgRepo() {
20210
20212
  try {
20211
20213
  const cached = await getCache(cacheKey);
20212
20214
  if (cached) {
20213
- logger13.log({
20215
+ logger14.log({
20214
20216
  level: "info",
20215
20217
  message: `Cache hit for getByName organization: ${cacheKey}`
20216
20218
  });
@@ -20220,13 +20222,13 @@ function useOrgRepo() {
20220
20222
  if (!result) {
20221
20223
  throw new BadRequestError22("Organization not found.");
20222
20224
  }
20223
- setCache(cacheKey, result, 300, namespace_collection).then(() => {
20224
- logger13.log({
20225
+ setCache(cacheKey, result, 300).then(() => {
20226
+ logger14.log({
20225
20227
  level: "info",
20226
20228
  message: `Cache set for organization by name: ${cacheKey}`
20227
20229
  });
20228
20230
  }).catch((err) => {
20229
- logger13.log({
20231
+ logger14.log({
20230
20232
  level: "error",
20231
20233
  message: `Failed to set cache for organization by name: ${err.message}`
20232
20234
  });
@@ -20299,9 +20301,9 @@ function useOrgRepo() {
20299
20301
  import {
20300
20302
  BadRequestError as BadRequestError24,
20301
20303
  useAtlas as useAtlas13,
20302
- useCache as useCache11,
20304
+ useCache as useCache12,
20303
20305
  makeCacheKey as makeCacheKey11,
20304
- logger as logger14
20306
+ logger as logger15
20305
20307
  } from "@eeplatform/nodejs-utils";
20306
20308
 
20307
20309
  // src/models/address.model.ts
@@ -20358,15 +20360,15 @@ function useAddressRepo() {
20358
20360
  }
20359
20361
  const namespace_collection = "addresses";
20360
20362
  const collection = db.collection(namespace_collection);
20361
- const { getCache, setCache, delNamespace } = useCache11();
20363
+ const { getCache, setCache, delNamespace } = useCache12(namespace_collection);
20362
20364
  function delCachedData() {
20363
- delNamespace(namespace_collection).then(() => {
20364
- logger14.log({
20365
+ delNamespace().then(() => {
20366
+ logger15.log({
20365
20367
  level: "info",
20366
20368
  message: `Cache namespace cleared for ${namespace_collection}`
20367
20369
  });
20368
20370
  }).catch((err) => {
20369
- logger14.log({
20371
+ logger15.log({
20370
20372
  level: "error",
20371
20373
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
20372
20374
  });
@@ -20428,7 +20430,7 @@ function useAddressRepo() {
20428
20430
  try {
20429
20431
  const cached = await getCache(cacheKey);
20430
20432
  if (cached) {
20431
- logger14.log({
20433
+ logger15.log({
20432
20434
  level: "info",
20433
20435
  message: `Cache hit for getByUserId address: ${cacheKey}`
20434
20436
  });
@@ -20436,13 +20438,13 @@ function useAddressRepo() {
20436
20438
  }
20437
20439
  const data = await collection.findOne({ user });
20438
20440
  if (data) {
20439
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
20440
- logger14.log({
20441
+ setCache(cacheKey, data, 300).then(() => {
20442
+ logger15.log({
20441
20443
  level: "info",
20442
20444
  message: `Cache set for address by user ID: ${cacheKey}`
20443
20445
  });
20444
20446
  }).catch((err) => {
20445
- logger14.log({
20447
+ logger15.log({
20446
20448
  level: "error",
20447
20449
  message: `Failed to set cache for address by user ID: ${err.message}`
20448
20450
  });
@@ -20463,7 +20465,7 @@ function useAddressRepo() {
20463
20465
  try {
20464
20466
  const cached = await getCache(cacheKey);
20465
20467
  if (cached) {
20466
- logger14.log({
20468
+ logger15.log({
20467
20469
  level: "info",
20468
20470
  message: `Cache hit for getByOrgId address: ${cacheKey}`
20469
20471
  });
@@ -20471,13 +20473,13 @@ function useAddressRepo() {
20471
20473
  }
20472
20474
  const data = await collection.findOne({ org });
20473
20475
  if (data) {
20474
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
20475
- logger14.log({
20476
+ setCache(cacheKey, data, 300).then(() => {
20477
+ logger15.log({
20476
20478
  level: "info",
20477
20479
  message: `Cache set for address by org ID: ${cacheKey}`
20478
20480
  });
20479
20481
  }).catch((err) => {
20480
- logger14.log({
20482
+ logger15.log({
20481
20483
  level: "error",
20482
20484
  message: `Failed to set cache for address by org ID: ${err.message}`
20483
20485
  });
@@ -20501,11 +20503,11 @@ function useAddressRepo() {
20501
20503
  import {
20502
20504
  BadRequestError as BadRequestError26,
20503
20505
  InternalServerError as InternalServerError17,
20504
- logger as logger15,
20506
+ logger as logger16,
20505
20507
  makeCacheKey as makeCacheKey12,
20506
20508
  paginate as paginate8,
20507
20509
  useAtlas as useAtlas14,
20508
- useCache as useCache12
20510
+ useCache as useCache13
20509
20511
  } from "@eeplatform/nodejs-utils";
20510
20512
 
20511
20513
  // src/validations/promo-code.schema.ts
@@ -20565,15 +20567,15 @@ function usePromoCodeRepo() {
20565
20567
  }
20566
20568
  const namespace_collection = "promo-codes";
20567
20569
  const collection = db.collection(namespace_collection);
20568
- const { getCache, setCache, delNamespace } = useCache12();
20570
+ const { getCache, setCache, delNamespace } = useCache13(namespace_collection);
20569
20571
  function delCachedData() {
20570
- delNamespace(namespace_collection).then(() => {
20571
- logger15.log({
20572
+ delNamespace().then(() => {
20573
+ logger16.log({
20572
20574
  level: "info",
20573
20575
  message: `Cache namespace cleared for ${namespace_collection}`
20574
20576
  });
20575
20577
  }).catch((err) => {
20576
- logger15.log({
20578
+ logger16.log({
20577
20579
  level: "error",
20578
20580
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
20579
20581
  });
@@ -20606,7 +20608,7 @@ function usePromoCodeRepo() {
20606
20608
  await collection.insertOne(value);
20607
20609
  delCachedData();
20608
20610
  } catch (error) {
20609
- logger15.log({ level: "error", message: `${error}` });
20611
+ logger16.log({ level: "error", message: `${error}` });
20610
20612
  const isDuplicated = error.message.includes("duplicate");
20611
20613
  if (isDuplicated) {
20612
20614
  throw new BadRequestError26("Promo code already exists.");
@@ -20639,7 +20641,7 @@ function usePromoCodeRepo() {
20639
20641
  try {
20640
20642
  const cached = await getCache(cacheKey);
20641
20643
  if (cached) {
20642
- logger15.log({
20644
+ logger16.log({
20643
20645
  level: "info",
20644
20646
  message: `Cache hit for getByCode promo code: ${cacheKey}`
20645
20647
  });
@@ -20647,13 +20649,13 @@ function usePromoCodeRepo() {
20647
20649
  }
20648
20650
  const data = await collection.findOne(query);
20649
20651
  if (data) {
20650
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
20651
- logger15.log({
20652
+ setCache(cacheKey, data, 300).then(() => {
20653
+ logger16.log({
20652
20654
  level: "info",
20653
20655
  message: `Cache set for promo code by code: ${cacheKey}`
20654
20656
  });
20655
20657
  }).catch((err) => {
20656
- logger15.log({
20658
+ logger16.log({
20657
20659
  level: "error",
20658
20660
  message: `Failed to set cache for promo code by code: ${err.message}`
20659
20661
  });
@@ -20681,7 +20683,7 @@ function usePromoCodeRepo() {
20681
20683
  try {
20682
20684
  const cached = await getCache(cacheKey);
20683
20685
  if (cached) {
20684
- logger15.log({
20686
+ logger16.log({
20685
20687
  level: "info",
20686
20688
  message: `Cache hit for getById promo code: ${cacheKey}`
20687
20689
  });
@@ -20689,13 +20691,13 @@ function usePromoCodeRepo() {
20689
20691
  }
20690
20692
  const data = await collection.findOne({ _id });
20691
20693
  if (data) {
20692
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
20693
- logger15.log({
20694
+ setCache(cacheKey, data, 300).then(() => {
20695
+ logger16.log({
20694
20696
  level: "info",
20695
20697
  message: `Cache set for promo code by ID: ${cacheKey}`
20696
20698
  });
20697
20699
  }).catch((err) => {
20698
- logger15.log({
20700
+ logger16.log({
20699
20701
  level: "error",
20700
20702
  message: `Failed to set cache for promo code by ID: ${err.message}`
20701
20703
  });
@@ -20734,7 +20736,7 @@ function usePromoCodeRepo() {
20734
20736
  try {
20735
20737
  const cached = await getCache(cacheKey);
20736
20738
  if (cached) {
20737
- logger15.log({
20739
+ logger16.log({
20738
20740
  level: "info",
20739
20741
  message: `Cache hit for getPromoCodes: ${cacheKey}`
20740
20742
  });
@@ -20748,20 +20750,20 @@ function usePromoCodeRepo() {
20748
20750
  ]).toArray();
20749
20751
  const length = await collection.countDocuments(query);
20750
20752
  const data = paginate8(items, page, limit, length);
20751
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
20752
- logger15.log({
20753
+ setCache(cacheKey, data, 600).then(() => {
20754
+ logger16.log({
20753
20755
  level: "info",
20754
20756
  message: `Cache set for getPromoCodes: ${cacheKey}`
20755
20757
  });
20756
20758
  }).catch((err) => {
20757
- logger15.log({
20759
+ logger16.log({
20758
20760
  level: "error",
20759
20761
  message: `Failed to set cache for getPromoCodes: ${err.message}`
20760
20762
  });
20761
20763
  });
20762
20764
  return data;
20763
20765
  } catch (error) {
20764
- logger15.log({ level: "error", message: `${error}` });
20766
+ logger16.log({ level: "error", message: `${error}` });
20765
20767
  throw new InternalServerError17("Internal server error.");
20766
20768
  }
20767
20769
  }
@@ -20808,7 +20810,7 @@ import Joi15 from "joi";
20808
20810
  import {
20809
20811
  BadRequestError as BadRequestError28,
20810
20812
  InternalServerError as InternalServerError18,
20811
- logger as logger16,
20813
+ logger as logger17,
20812
20814
  paginate as paginate9,
20813
20815
  useAtlas as useAtlas15
20814
20816
  } from "@eeplatform/nodejs-utils";
@@ -20943,7 +20945,7 @@ function useInvoiceRepo() {
20943
20945
  value = createInvoice(value);
20944
20946
  await collection.insertOne(value, { session });
20945
20947
  } catch (error) {
20946
- logger16.log({ level: "error", message: `${error}` });
20948
+ logger17.log({ level: "error", message: `${error}` });
20947
20949
  const isDuplicated = error.message.includes("duplicate");
20948
20950
  if (isDuplicated) {
20949
20951
  throw new BadRequestError28("Invoice already exists.");
@@ -21078,9 +21080,9 @@ function useInvoiceRepo() {
21078
21080
  // src/repositories/counter.repository.ts
21079
21081
  import {
21080
21082
  useAtlas as useAtlas16,
21081
- useCache as useCache13,
21083
+ useCache as useCache14,
21082
21084
  makeCacheKey as makeCacheKey13,
21083
- logger as logger17
21085
+ logger as logger18
21084
21086
  } from "@eeplatform/nodejs-utils";
21085
21087
 
21086
21088
  // src/models/counter.model.ts
@@ -21125,15 +21127,15 @@ function useCounterRepo() {
21125
21127
  }
21126
21128
  const namespace_collection = "counters";
21127
21129
  const { collection, createCounter } = useCounterModel(db);
21128
- const { getCache, setCache, delNamespace } = useCache13();
21130
+ const { getCache, setCache, delNamespace } = useCache14(namespace_collection);
21129
21131
  function delCachedData() {
21130
- delNamespace(namespace_collection).then(() => {
21131
- logger17.log({
21132
+ delNamespace().then(() => {
21133
+ logger18.log({
21132
21134
  level: "info",
21133
21135
  message: `Cache namespace cleared for ${namespace_collection}`
21134
21136
  });
21135
21137
  }).catch((err) => {
21136
- logger17.log({
21138
+ logger18.log({
21137
21139
  level: "error",
21138
21140
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
21139
21141
  });
@@ -21189,7 +21191,7 @@ function useCounterRepo() {
21189
21191
  try {
21190
21192
  const cached = await getCache(cacheKey);
21191
21193
  if (cached) {
21192
- logger17.log({
21194
+ logger18.log({
21193
21195
  level: "info",
21194
21196
  message: `Cache hit for getByType counter: ${cacheKey}`
21195
21197
  });
@@ -21197,13 +21199,13 @@ function useCounterRepo() {
21197
21199
  }
21198
21200
  const data = await collection.findOne({ type });
21199
21201
  if (data) {
21200
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
21201
- logger17.log({
21202
+ setCache(cacheKey, data, 300).then(() => {
21203
+ logger18.log({
21202
21204
  level: "info",
21203
21205
  message: `Cache set for counter by type: ${cacheKey}`
21204
21206
  });
21205
21207
  }).catch((err) => {
21206
- logger17.log({
21208
+ logger18.log({
21207
21209
  level: "error",
21208
21210
  message: `Failed to set cache for counter by type: ${err.message}`
21209
21211
  });
@@ -21227,7 +21229,7 @@ function useCounterRepo() {
21227
21229
  import {
21228
21230
  BadRequestError as BadRequestError30,
21229
21231
  InternalServerError as InternalServerError19,
21230
- logger as logger18,
21232
+ logger as logger19,
21231
21233
  paginate as paginate10,
21232
21234
  useAtlas as useAtlas17
21233
21235
  } from "@eeplatform/nodejs-utils";
@@ -21272,7 +21274,7 @@ function usePaymentRepo() {
21272
21274
  value = createPayment(value);
21273
21275
  await collection.insertOne(value, { session });
21274
21276
  } catch (error) {
21275
- logger18.log({ level: "error", message: `${error}` });
21277
+ logger19.log({ level: "error", message: `${error}` });
21276
21278
  const isDuplicated = error.message.includes("duplicate");
21277
21279
  if (isDuplicated) {
21278
21280
  throw new BadRequestError30("Payment already exists.");
@@ -21317,7 +21319,7 @@ function usePaymentRepo() {
21317
21319
  const length = await collection.countDocuments(query);
21318
21320
  return paginate10(items, page, limit, length);
21319
21321
  } catch (error) {
21320
- logger18.log({ level: "error", message: `${error}` });
21322
+ logger19.log({ level: "error", message: `${error}` });
21321
21323
  throw new InternalServerError19("Internal server error.");
21322
21324
  }
21323
21325
  }
@@ -21345,9 +21347,9 @@ function usePaymentRepo() {
21345
21347
  // src/repositories/price.repository.ts
21346
21348
  import {
21347
21349
  useAtlas as useAtlas18,
21348
- useCache as useCache14,
21350
+ useCache as useCache15,
21349
21351
  makeCacheKey as makeCacheKey14,
21350
- logger as logger19
21352
+ logger as logger20
21351
21353
  } from "@eeplatform/nodejs-utils";
21352
21354
 
21353
21355
  // src/models/price.model.ts
@@ -21401,15 +21403,15 @@ function usePriceRepo() {
21401
21403
  }
21402
21404
  const namespace_collection = "prices";
21403
21405
  const { collection, createPrice } = usePriceModel(db);
21404
- const { getCache, setCache, delNamespace } = useCache14();
21406
+ const { getCache, setCache, delNamespace } = useCache15(namespace_collection);
21405
21407
  function delCachedData() {
21406
- delNamespace(namespace_collection).then(() => {
21407
- logger19.log({
21408
+ delNamespace().then(() => {
21409
+ logger20.log({
21408
21410
  level: "info",
21409
21411
  message: `Cache namespace cleared for ${namespace_collection}`
21410
21412
  });
21411
21413
  }).catch((err) => {
21412
- logger19.log({
21414
+ logger20.log({
21413
21415
  level: "error",
21414
21416
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
21415
21417
  });
@@ -21465,7 +21467,7 @@ function usePriceRepo() {
21465
21467
  try {
21466
21468
  const cached = await getCache(cacheKey);
21467
21469
  if (cached) {
21468
- logger19.log({
21470
+ logger20.log({
21469
21471
  level: "info",
21470
21472
  message: `Cache hit for getByNameType price: ${cacheKey}`
21471
21473
  });
@@ -21473,13 +21475,13 @@ function usePriceRepo() {
21473
21475
  }
21474
21476
  const data = await collection.findOne({ name, type });
21475
21477
  if (data) {
21476
- setCache(cacheKey, data, 300, namespace_collection).then(() => {
21477
- logger19.log({
21478
+ setCache(cacheKey, data, 300).then(() => {
21479
+ logger20.log({
21478
21480
  level: "info",
21479
21481
  message: `Cache set for price by name and type: ${cacheKey}`
21480
21482
  });
21481
21483
  }).catch((err) => {
21482
- logger19.log({
21484
+ logger20.log({
21483
21485
  level: "error",
21484
21486
  message: `Failed to set cache for price by name and type: ${err.message}`
21485
21487
  });
@@ -22251,7 +22253,7 @@ function useSubscriptionService() {
22251
22253
  while (true) {
22252
22254
  const subscriptions = await getDueSubscriptions(batchSize);
22253
22255
  if (subscriptions.length === 0) {
22254
- logger20.log({
22256
+ logger21.log({
22255
22257
  level: "info",
22256
22258
  message: "No more subscriptions to process."
22257
22259
  });
@@ -22391,14 +22393,14 @@ function useSubscriptionService() {
22391
22393
  );
22392
22394
  await session?.commitTransaction();
22393
22395
  }
22394
- logger20.log({
22396
+ logger21.log({
22395
22397
  level: "info",
22396
22398
  message: `Processed subscription ${sub._id} successfully.`
22397
22399
  });
22398
22400
  return;
22399
22401
  } catch (error) {
22400
22402
  await session?.abortTransaction();
22401
- logger20.log({
22403
+ logger21.log({
22402
22404
  level: "error",
22403
22405
  message: `Failed to process ${sub._id}: ${error}`
22404
22406
  });
@@ -22410,7 +22412,7 @@ function useSubscriptionService() {
22410
22412
  }
22411
22413
  })
22412
22414
  );
22413
- logger20.log({
22415
+ logger21.log({
22414
22416
  level: "info",
22415
22417
  message: "Processed a batch of subscriptions."
22416
22418
  });
@@ -22707,7 +22709,7 @@ function useSubscriptionService() {
22707
22709
  await session?.commitTransaction();
22708
22710
  } catch (error2) {
22709
22711
  await session?.abortTransaction();
22710
- logger20.log({
22712
+ logger21.log({
22711
22713
  level: "error",
22712
22714
  message: `Failed to update subscription seats: ${error2}`
22713
22715
  });
@@ -22908,7 +22910,7 @@ function useSubscriptionService() {
22908
22910
  await session?.commitTransaction();
22909
22911
  } catch (error2) {
22910
22912
  await session?.abortTransaction();
22911
- logger20.log({
22913
+ logger21.log({
22912
22914
  level: "error",
22913
22915
  message: `Failed to update subscription seats: ${error2}`
22914
22916
  });
@@ -23009,7 +23011,7 @@ function useSubscriptionService() {
23009
23011
  await session?.commitTransaction();
23010
23012
  } catch (error) {
23011
23013
  await session?.abortTransaction();
23012
- logger20.log({
23014
+ logger21.log({
23013
23015
  level: "error",
23014
23016
  message: `Failed to process subscription payment: ${error}`
23015
23017
  });
@@ -23512,7 +23514,7 @@ function MPaymentMethod(value) {
23512
23514
  import {
23513
23515
  BadRequestError as BadRequestError36,
23514
23516
  InternalServerError as InternalServerError20,
23515
- logger as logger21,
23517
+ logger as logger22,
23516
23518
  useAtlas as useAtlas20
23517
23519
  } from "@eeplatform/nodejs-utils";
23518
23520
  import { ObjectId as ObjectId30 } from "mongodb";
@@ -23558,7 +23560,7 @@ function usePaymentMethodRepo() {
23558
23560
  await collection.insertOne(value, { session });
23559
23561
  return "Successfully added payment method.";
23560
23562
  } catch (error) {
23561
- logger21.log({ level: "error", message: `${error}` });
23563
+ logger22.log({ level: "error", message: `${error}` });
23562
23564
  const isDuplicated = error.message.includes("duplicate");
23563
23565
  if (isDuplicated) {
23564
23566
  throw new BadRequestError36("Payment method already exist.");
@@ -24731,11 +24733,11 @@ import {
24731
24733
  AppError as AppError11,
24732
24734
  BadRequestError as BadRequestError44,
24733
24735
  InternalServerError as InternalServerError22,
24734
- logger as logger22,
24736
+ logger as logger23,
24735
24737
  makeCacheKey as makeCacheKey15,
24736
24738
  paginate as paginate11,
24737
24739
  useAtlas as useAtlas23,
24738
- useCache as useCache15
24740
+ useCache as useCache16
24739
24741
  } from "@eeplatform/nodejs-utils";
24740
24742
  import { ObjectId as ObjectId32 } from "mongodb";
24741
24743
  function useOrderRepo() {
@@ -24745,15 +24747,15 @@ function useOrderRepo() {
24745
24747
  }
24746
24748
  const namespace_collection = "orders";
24747
24749
  const collection = db.collection(namespace_collection);
24748
- const { getCache, setCache, delNamespace } = useCache15();
24750
+ const { getCache, setCache, delNamespace } = useCache16(namespace_collection);
24749
24751
  function delCachedData() {
24750
- delNamespace(namespace_collection).then(() => {
24751
- logger22.log({
24752
+ delNamespace().then(() => {
24753
+ logger23.log({
24752
24754
  level: "info",
24753
24755
  message: `Cache namespace cleared for ${namespace_collection}`
24754
24756
  });
24755
24757
  }).catch((err) => {
24756
- logger22.log({
24758
+ logger23.log({
24757
24759
  level: "error",
24758
24760
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
24759
24761
  });
@@ -24776,7 +24778,7 @@ function useOrderRepo() {
24776
24778
  collection.insertOne(value, { session });
24777
24779
  delCachedData();
24778
24780
  } catch (error) {
24779
- logger22.log({ level: "error", message: `${error}` });
24781
+ logger23.log({ level: "error", message: `${error}` });
24780
24782
  if (error instanceof AppError11) {
24781
24783
  throw error;
24782
24784
  }
@@ -24820,7 +24822,7 @@ function useOrderRepo() {
24820
24822
  try {
24821
24823
  const cached = await getCache(cacheKey);
24822
24824
  if (cached) {
24823
- logger22.log({
24825
+ logger23.log({
24824
24826
  level: "info",
24825
24827
  message: `Cache hit for getOrders: ${cacheKey}`
24826
24828
  });
@@ -24834,20 +24836,20 @@ function useOrderRepo() {
24834
24836
  ]).toArray();
24835
24837
  const length = await collection.countDocuments(query);
24836
24838
  const data = paginate11(items, page, limit, length);
24837
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
24838
- logger22.log({
24839
+ setCache(cacheKey, data, 600).then(() => {
24840
+ logger23.log({
24839
24841
  level: "info",
24840
24842
  message: `Cache set for getOrders: ${cacheKey}`
24841
24843
  });
24842
24844
  }).catch((err) => {
24843
- logger22.log({
24845
+ logger23.log({
24844
24846
  level: "error",
24845
24847
  message: `Failed to set cache for getOrders: ${err.message}`
24846
24848
  });
24847
24849
  });
24848
24850
  return data;
24849
24851
  } catch (error) {
24850
- logger22.log({ level: "error", message: `${error}` });
24852
+ logger23.log({ level: "error", message: `${error}` });
24851
24853
  throw new InternalServerError22("Internal server error.");
24852
24854
  }
24853
24855
  }
@@ -24903,7 +24905,7 @@ function useOrderController() {
24903
24905
  // src/services/invoice.service.ts
24904
24906
  import {
24905
24907
  BadRequestError as BadRequestError46,
24906
- logger as logger23,
24908
+ logger as logger24,
24907
24909
  NotFoundError as NotFoundError7,
24908
24910
  useAtlas as useAtlas24
24909
24911
  } from "@eeplatform/nodejs-utils";
@@ -24925,7 +24927,7 @@ function useInvoiceService() {
24925
24927
  while (true) {
24926
24928
  const overdueInvoices = await getOverdueInvoices(BATCH_SIZE);
24927
24929
  if (!overdueInvoices.length) {
24928
- logger23.log({
24930
+ logger24.log({
24929
24931
  level: "info",
24930
24932
  message: "No overdue invoices found."
24931
24933
  });
@@ -24935,21 +24937,21 @@ function useInvoiceService() {
24935
24937
  overdueInvoices.map(async (invoice) => {
24936
24938
  const session = useAtlas24.getClient()?.startSession();
24937
24939
  if (!session) {
24938
- logger23.log({
24940
+ logger24.log({
24939
24941
  level: "error",
24940
24942
  message: "Failed to start session."
24941
24943
  });
24942
24944
  return;
24943
24945
  }
24944
24946
  if (!invoice._id) {
24945
- logger23.log({
24947
+ logger24.log({
24946
24948
  level: "error",
24947
24949
  message: "Invoice ID is missing."
24948
24950
  });
24949
24951
  return;
24950
24952
  }
24951
24953
  if (!invoice.metadata?.subscriptionId) {
24952
- logger23.log({
24954
+ logger24.log({
24953
24955
  level: "error",
24954
24956
  message: "Subscription ID is missing."
24955
24957
  });
@@ -24959,14 +24961,14 @@ function useInvoiceService() {
24959
24961
  invoice.metadata.subscriptionId
24960
24962
  ).catch(() => null);
24961
24963
  if (!subscription) {
24962
- logger23.log({
24964
+ logger24.log({
24963
24965
  level: "error",
24964
24966
  message: "Subscription not found."
24965
24967
  });
24966
24968
  return;
24967
24969
  }
24968
24970
  if (!subscription._id) {
24969
- logger23.log({
24971
+ logger24.log({
24970
24972
  level: "error",
24971
24973
  message: "Subscription ID is missing."
24972
24974
  });
@@ -25046,7 +25048,7 @@ function useInvoiceService() {
25046
25048
  return;
25047
25049
  }
25048
25050
  } catch (error) {
25049
- logger23.log({
25051
+ logger24.log({
25050
25052
  level: "error",
25051
25053
  message: String(error)
25052
25054
  });
@@ -25056,7 +25058,7 @@ function useInvoiceService() {
25056
25058
  }
25057
25059
  })
25058
25060
  );
25059
- logger23.log({
25061
+ logger24.log({
25060
25062
  level: "info",
25061
25063
  message: "Successfully processed overdue invoices."
25062
25064
  });
@@ -25068,7 +25070,7 @@ function useInvoiceService() {
25068
25070
  }
25069
25071
  const session = useAtlas24.getClient()?.startSession();
25070
25072
  if (!session) {
25071
- logger23.log({
25073
+ logger24.log({
25072
25074
  level: "error",
25073
25075
  message: "Failed to start session."
25074
25076
  });
@@ -25137,7 +25139,7 @@ function useInvoiceService() {
25137
25139
  return "Payment processed successfully.";
25138
25140
  } catch (error) {
25139
25141
  session.abortTransaction();
25140
- logger23.log({
25142
+ logger24.log({
25141
25143
  level: "error",
25142
25144
  message: String(error)
25143
25145
  });
@@ -25384,11 +25386,11 @@ import {
25384
25386
  AppError as AppError12,
25385
25387
  BadRequestError as BadRequestError51,
25386
25388
  InternalServerError as InternalServerError23,
25387
- logger as logger24,
25389
+ logger as logger25,
25388
25390
  makeCacheKey as makeCacheKey16,
25389
25391
  paginate as paginate12,
25390
25392
  useAtlas as useAtlas25,
25391
- useCache as useCache16
25393
+ useCache as useCache17
25392
25394
  } from "@eeplatform/nodejs-utils";
25393
25395
  import { ObjectId as ObjectId34 } from "mongodb";
25394
25396
  function useRegionRepo() {
@@ -25398,7 +25400,7 @@ function useRegionRepo() {
25398
25400
  }
25399
25401
  const namespace_collection = "regions";
25400
25402
  const collection = db.collection(namespace_collection);
25401
- const { getCache, setCache, delNamespace } = useCache16();
25403
+ const { getCache, setCache, delNamespace } = useCache17(namespace_collection);
25402
25404
  async function createIndex() {
25403
25405
  try {
25404
25406
  await collection.createIndex([
@@ -25435,13 +25437,13 @@ function useRegionRepo() {
25435
25437
  }
25436
25438
  }
25437
25439
  function delCachedData() {
25438
- delNamespace(namespace_collection).then(() => {
25439
- logger24.log({
25440
+ delNamespace().then(() => {
25441
+ logger25.log({
25440
25442
  level: "info",
25441
25443
  message: `Cache namespace cleared for ${namespace_collection}`
25442
25444
  });
25443
25445
  }).catch((err) => {
25444
- logger24.log({
25446
+ logger25.log({
25445
25447
  level: "error",
25446
25448
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
25447
25449
  });
@@ -25454,7 +25456,7 @@ function useRegionRepo() {
25454
25456
  delCachedData();
25455
25457
  return res.insertedId;
25456
25458
  } catch (error) {
25457
- logger24.log({
25459
+ logger25.log({
25458
25460
  level: "error",
25459
25461
  message: error.message
25460
25462
  });
@@ -25482,14 +25484,14 @@ function useRegionRepo() {
25482
25484
  limit,
25483
25485
  sort: JSON.stringify(sort)
25484
25486
  });
25485
- logger24.log({
25487
+ logger25.log({
25486
25488
  level: "info",
25487
25489
  message: `Cache key for getAll regions: ${cacheKey}`
25488
25490
  });
25489
25491
  try {
25490
25492
  const cached = await getCache(cacheKey);
25491
25493
  if (cached) {
25492
- logger24.log({
25494
+ logger25.log({
25493
25495
  level: "info",
25494
25496
  message: `Cache hit for getAll regions: ${cacheKey}`
25495
25497
  });
@@ -25513,20 +25515,20 @@ function useRegionRepo() {
25513
25515
  ]).toArray();
25514
25516
  const length = await collection.countDocuments(query);
25515
25517
  const data = paginate12(items, page, limit, length);
25516
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
25517
- logger24.log({
25518
+ setCache(cacheKey, data, 600).then(() => {
25519
+ logger25.log({
25518
25520
  level: "info",
25519
25521
  message: `Cache set for getAll regions: ${cacheKey}`
25520
25522
  });
25521
25523
  }).catch((err) => {
25522
- logger24.log({
25524
+ logger25.log({
25523
25525
  level: "error",
25524
25526
  message: `Failed to set cache for getAll regions: ${err.message}`
25525
25527
  });
25526
25528
  });
25527
25529
  return data;
25528
25530
  } catch (error) {
25529
- logger24.log({ level: "error", message: `${error}` });
25531
+ logger25.log({ level: "error", message: `${error}` });
25530
25532
  throw error;
25531
25533
  }
25532
25534
  }
@@ -25540,7 +25542,7 @@ function useRegionRepo() {
25540
25542
  try {
25541
25543
  const cached = await getCache(cacheKey);
25542
25544
  if (cached) {
25543
- logger24.log({
25545
+ logger25.log({
25544
25546
  level: "info",
25545
25547
  message: `Cache hit for getById region: ${cacheKey}`
25546
25548
  });
@@ -25553,13 +25555,13 @@ function useRegionRepo() {
25553
25555
  if (!result) {
25554
25556
  throw new BadRequestError51("Region not found.");
25555
25557
  }
25556
- setCache(cacheKey, result, 300, namespace_collection).then(() => {
25557
- logger24.log({
25558
+ setCache(cacheKey, result, 300).then(() => {
25559
+ logger25.log({
25558
25560
  level: "info",
25559
25561
  message: `Cache set for region by id: ${cacheKey}`
25560
25562
  });
25561
25563
  }).catch((err) => {
25562
- logger24.log({
25564
+ logger25.log({
25563
25565
  level: "error",
25564
25566
  message: `Failed to set cache for region by id: ${err.message}`
25565
25567
  });
@@ -25578,7 +25580,7 @@ function useRegionRepo() {
25578
25580
  try {
25579
25581
  const cached = await getCache(cacheKey);
25580
25582
  if (cached) {
25581
- logger24.log({
25583
+ logger25.log({
25582
25584
  level: "info",
25583
25585
  message: `Cache hit for getByName region: ${cacheKey}`
25584
25586
  });
@@ -25591,13 +25593,13 @@ function useRegionRepo() {
25591
25593
  if (!result) {
25592
25594
  throw new BadRequestError51("Region not found.");
25593
25595
  }
25594
- setCache(cacheKey, result, 300, namespace_collection).then(() => {
25595
- logger24.log({
25596
+ setCache(cacheKey, result, 300).then(() => {
25597
+ logger25.log({
25596
25598
  level: "info",
25597
25599
  message: `Cache set for region by name: ${cacheKey}`
25598
25600
  });
25599
25601
  }).catch((err) => {
25600
- logger24.log({
25602
+ logger25.log({
25601
25603
  level: "error",
25602
25604
  message: `Failed to set cache for region by name: ${err.message}`
25603
25605
  });
@@ -25923,11 +25925,11 @@ import {
25923
25925
  AppError as AppError13,
25924
25926
  BadRequestError as BadRequestError54,
25925
25927
  InternalServerError as InternalServerError24,
25926
- logger as logger25,
25928
+ logger as logger26,
25927
25929
  makeCacheKey as makeCacheKey17,
25928
25930
  paginate as paginate13,
25929
25931
  useAtlas as useAtlas27,
25930
- useCache as useCache17
25932
+ useCache as useCache18
25931
25933
  } from "@eeplatform/nodejs-utils";
25932
25934
  import { ObjectId as ObjectId36 } from "mongodb";
25933
25935
  function useDivisionRepo() {
@@ -25937,7 +25939,7 @@ function useDivisionRepo() {
25937
25939
  }
25938
25940
  const namespace_collection = "divisions";
25939
25941
  const collection = db.collection(namespace_collection);
25940
- const { getCache, setCache, delNamespace } = useCache17();
25942
+ const { getCache, setCache, delNamespace } = useCache18(namespace_collection);
25941
25943
  async function createIndex() {
25942
25944
  try {
25943
25945
  await collection.createIndex([
@@ -25976,13 +25978,13 @@ function useDivisionRepo() {
25976
25978
  }
25977
25979
  }
25978
25980
  function delCachedData() {
25979
- delNamespace(namespace_collection).then(() => {
25980
- logger25.log({
25981
+ delNamespace().then(() => {
25982
+ logger26.log({
25981
25983
  level: "info",
25982
25984
  message: `Cache namespace cleared for ${namespace_collection}`
25983
25985
  });
25984
25986
  }).catch((err) => {
25985
- logger25.log({
25987
+ logger26.log({
25986
25988
  level: "error",
25987
25989
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
25988
25990
  });
@@ -25995,7 +25997,7 @@ function useDivisionRepo() {
25995
25997
  delCachedData();
25996
25998
  return res.insertedId;
25997
25999
  } catch (error) {
25998
- logger25.log({
26000
+ logger26.log({
25999
26001
  level: "error",
26000
26002
  message: error.message
26001
26003
  });
@@ -26037,14 +26039,14 @@ function useDivisionRepo() {
26037
26039
  sort: JSON.stringify(sort),
26038
26040
  region
26039
26041
  });
26040
- logger25.log({
26042
+ logger26.log({
26041
26043
  level: "info",
26042
26044
  message: `Cache key for getAll divisions: ${cacheKey}`
26043
26045
  });
26044
26046
  try {
26045
26047
  const cached = await getCache(cacheKey);
26046
26048
  if (cached) {
26047
- logger25.log({
26049
+ logger26.log({
26048
26050
  level: "info",
26049
26051
  message: `Cache hit for getAll divisions: ${cacheKey}`
26050
26052
  });
@@ -26070,20 +26072,20 @@ function useDivisionRepo() {
26070
26072
  ]).toArray();
26071
26073
  const length = await collection.countDocuments(query);
26072
26074
  const data = paginate13(items, page, limit, length);
26073
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
26074
- logger25.log({
26075
+ setCache(cacheKey, data, 600).then(() => {
26076
+ logger26.log({
26075
26077
  level: "info",
26076
26078
  message: `Cache set for getAll divisions: ${cacheKey}`
26077
26079
  });
26078
26080
  }).catch((err) => {
26079
- logger25.log({
26081
+ logger26.log({
26080
26082
  level: "error",
26081
26083
  message: `Failed to set cache for getAll divisions: ${err.message}`
26082
26084
  });
26083
26085
  });
26084
26086
  return data;
26085
26087
  } catch (error) {
26086
- logger25.log({ level: "error", message: `${error}` });
26088
+ logger26.log({ level: "error", message: `${error}` });
26087
26089
  throw error;
26088
26090
  }
26089
26091
  }
@@ -26097,7 +26099,7 @@ function useDivisionRepo() {
26097
26099
  try {
26098
26100
  const cached = await getCache(cacheKey);
26099
26101
  if (cached) {
26100
- logger25.log({
26102
+ logger26.log({
26101
26103
  level: "info",
26102
26104
  message: `Cache hit for getById division: ${cacheKey}`
26103
26105
  });
@@ -26110,13 +26112,13 @@ function useDivisionRepo() {
26110
26112
  if (!result) {
26111
26113
  throw new BadRequestError54("Division not found.");
26112
26114
  }
26113
- setCache(cacheKey, result, 300, namespace_collection).then(() => {
26114
- logger25.log({
26115
+ setCache(cacheKey, result, 300).then(() => {
26116
+ logger26.log({
26115
26117
  level: "info",
26116
26118
  message: `Cache set for division by id: ${cacheKey}`
26117
26119
  });
26118
26120
  }).catch((err) => {
26119
- logger25.log({
26121
+ logger26.log({
26120
26122
  level: "error",
26121
26123
  message: `Failed to set cache for division by id: ${err.message}`
26122
26124
  });
@@ -26135,7 +26137,7 @@ function useDivisionRepo() {
26135
26137
  try {
26136
26138
  const cached = await getCache(cacheKey);
26137
26139
  if (cached) {
26138
- logger25.log({
26140
+ logger26.log({
26139
26141
  level: "info",
26140
26142
  message: `Cache hit for getByName division: ${cacheKey}`
26141
26143
  });
@@ -26148,13 +26150,13 @@ function useDivisionRepo() {
26148
26150
  if (!result) {
26149
26151
  throw new BadRequestError54("Division not found.");
26150
26152
  }
26151
- setCache(cacheKey, result, 300, namespace_collection).then(() => {
26152
- logger25.log({
26153
+ setCache(cacheKey, result, 300).then(() => {
26154
+ logger26.log({
26153
26155
  level: "info",
26154
26156
  message: `Cache set for division by name: ${cacheKey}`
26155
26157
  });
26156
26158
  }).catch((err) => {
26157
- logger25.log({
26159
+ logger26.log({
26158
26160
  level: "error",
26159
26161
  message: `Failed to set cache for division by name: ${err.message}`
26160
26162
  });
@@ -26524,11 +26526,11 @@ function MSchool(value) {
26524
26526
  // src/repositories/school.repository.ts
26525
26527
  import {
26526
26528
  BadRequestError as BadRequestError56,
26527
- logger as logger26,
26529
+ logger as logger27,
26528
26530
  makeCacheKey as makeCacheKey18,
26529
26531
  paginate as paginate14,
26530
26532
  useAtlas as useAtlas29,
26531
- useCache as useCache18
26533
+ useCache as useCache19
26532
26534
  } from "@eeplatform/nodejs-utils";
26533
26535
  import { ObjectId as ObjectId38 } from "mongodb";
26534
26536
  function useSchoolRepo() {
@@ -26538,15 +26540,15 @@ function useSchoolRepo() {
26538
26540
  }
26539
26541
  const namespace_collection = "schools";
26540
26542
  const collection = db.collection(namespace_collection);
26541
- const { getCache, setCache, delNamespace } = useCache18();
26543
+ const { getCache, setCache, delNamespace } = useCache19(namespace_collection);
26542
26544
  function delCachedData() {
26543
- delNamespace(namespace_collection).then(() => {
26544
- logger26.log({
26545
+ delNamespace().then(() => {
26546
+ logger27.log({
26545
26547
  level: "info",
26546
26548
  message: `Cache namespace cleared for ${namespace_collection}`
26547
26549
  });
26548
26550
  }).catch((err) => {
26549
- logger26.log({
26551
+ logger27.log({
26550
26552
  level: "error",
26551
26553
  message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
26552
26554
  });
@@ -26583,7 +26585,7 @@ function useSchoolRepo() {
26583
26585
  delCachedData();
26584
26586
  return res.insertedId;
26585
26587
  } catch (error) {
26586
- logger26.log({
26588
+ logger27.log({
26587
26589
  level: "error",
26588
26590
  message: `Failed to add school: ${error}`
26589
26591
  });
@@ -26640,20 +26642,20 @@ function useSchoolRepo() {
26640
26642
  ]).toArray();
26641
26643
  const length = await collection.countDocuments(query);
26642
26644
  const data = paginate14(items, page, limit, length);
26643
- setCache(cacheKey, data, 600, namespace_collection).then(() => {
26644
- logger26.log({
26645
+ setCache(cacheKey, data, 600).then(() => {
26646
+ logger27.log({
26645
26647
  level: "info",
26646
26648
  message: `Cache set for key ${cacheKey}`
26647
26649
  });
26648
26650
  }).catch((err) => {
26649
- logger26.log({
26651
+ logger27.log({
26650
26652
  level: "error",
26651
26653
  message: `Failed to set cache for key ${cacheKey}: ${err.message}`
26652
26654
  });
26653
26655
  });
26654
26656
  return data;
26655
26657
  } catch (error) {
26656
- logger26.log({
26658
+ logger27.log({
26657
26659
  level: "error",
26658
26660
  message: `Failed to get all schools: ${error}`
26659
26661
  });
@@ -26731,13 +26733,13 @@ function useSchoolRepo() {
26731
26733
  }
26732
26734
  try {
26733
26735
  const school = await collection.findOne({ createdBy, status: "pending" });
26734
- setCache(cacheKey, school, 600, namespace_collection).then(() => {
26735
- logger26.log({
26736
+ setCache(cacheKey, school, 600).then(() => {
26737
+ logger27.log({
26736
26738
  level: "info",
26737
26739
  message: `Cache set for school by createdBy: ${cacheKey}`
26738
26740
  });
26739
26741
  }).catch((err) => {
26740
- logger26.log({
26742
+ logger27.log({
26741
26743
  level: "error",
26742
26744
  message: `Failed to set cache for school by createdBy: ${err.message}`
26743
26745
  });
@@ -26763,13 +26765,13 @@ function useSchoolRepo() {
26763
26765
  }
26764
26766
  try {
26765
26767
  const school = await collection.findOne({ _id, status: "pending" });
26766
- setCache(cacheKey, school, 600, namespace_collection).then(() => {
26767
- logger26.log({
26768
+ setCache(cacheKey, school, 600).then(() => {
26769
+ logger27.log({
26768
26770
  level: "info",
26769
26771
  message: `Cache set for school by ID: ${cacheKey}`
26770
26772
  });
26771
26773
  }).catch((err) => {
26772
- logger26.log({
26774
+ logger27.log({
26773
26775
  level: "error",
26774
26776
  message: `Failed to set cache for school by ID: ${err.message}`
26775
26777
  });
@@ -26791,7 +26793,7 @@ function useSchoolRepo() {
26791
26793
  }
26792
26794
 
26793
26795
  // src/services/school.service.ts
26794
- import { BadRequestError as BadRequestError57, useAtlas as useAtlas30, logger as logger27 } from "@eeplatform/nodejs-utils";
26796
+ import { BadRequestError as BadRequestError57, useAtlas as useAtlas30, logger as logger28 } from "@eeplatform/nodejs-utils";
26795
26797
  function useSchoolService() {
26796
26798
  const { add, getPendingByCreatedBy, updateStatusById, getPendingById } = useSchoolRepo();
26797
26799
  const { addRole } = useRoleRepo();
@@ -26864,7 +26866,7 @@ function useSchoolService() {
26864
26866
  await session.commitTransaction();
26865
26867
  return "School registration has been approved.";
26866
26868
  } catch (error) {
26867
- logger27.log({
26869
+ logger28.log({
26868
26870
  level: "error",
26869
26871
  message: `Error approving school registration: ${error.message}`
26870
26872
  });