@akanjs/nest 0.0.97 → 0.0.98

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.
Files changed (46) hide show
  1. package/index.cjs +21 -0
  2. package/index.js +1 -21
  3. package/package.json +2 -2
  4. package/src/{authGuards.mjs → authGuards.cjs} +56 -15
  5. package/src/authGuards.js +15 -56
  6. package/src/authentication.cjs +122 -0
  7. package/src/authentication.js +27 -67
  8. package/src/authorization.cjs +79 -0
  9. package/src/authorization.js +12 -46
  10. package/src/cacheClient.cjs +45 -0
  11. package/src/cacheClient.js +5 -26
  12. package/src/databaseClient.cjs +51 -0
  13. package/src/databaseClient.js +8 -29
  14. package/src/{decorators.mjs → decorators.cjs} +33 -6
  15. package/src/decorators.js +6 -33
  16. package/src/{exceptions.mjs → exceptions.cjs} +29 -8
  17. package/src/exceptions.js +8 -29
  18. package/src/{exporter.mjs → exporter.cjs} +40 -3
  19. package/src/exporter.js +3 -40
  20. package/src/{generateSecrets.mjs → generateSecrets.cjs} +43 -13
  21. package/src/generateSecrets.js +13 -43
  22. package/src/index.cjs +73 -0
  23. package/src/index.js +21 -72
  24. package/src/{interceptors.mjs → interceptors.cjs} +55 -36
  25. package/src/interceptors.js +36 -55
  26. package/src/mongoose.cjs +93 -0
  27. package/src/mongoose.js +11 -44
  28. package/src/{pipes.mjs → pipes.cjs} +51 -22
  29. package/src/pipes.js +22 -51
  30. package/src/redis-io.adapter.cjs +84 -0
  31. package/src/redis-io.adapter.js +12 -35
  32. package/src/{searchClient.mjs → searchClient.cjs} +28 -7
  33. package/src/searchClient.js +7 -28
  34. package/src/{sso.mjs → sso.cjs} +56 -24
  35. package/src/sso.js +24 -56
  36. package/src/verifyPayment.cjs +50 -0
  37. package/src/verifyPayment.js +4 -37
  38. package/index.mjs +0 -1
  39. package/src/authentication.mjs +0 -82
  40. package/src/authorization.mjs +0 -45
  41. package/src/cacheClient.mjs +0 -24
  42. package/src/databaseClient.mjs +0 -30
  43. package/src/index.mjs +0 -22
  44. package/src/mongoose.mjs +0 -60
  45. package/src/redis-io.adapter.mjs +0 -61
  46. package/src/verifyPayment.mjs +0 -17
@@ -0,0 +1,79 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var authorization_exports = {};
29
+ __export(authorization_exports, {
30
+ allow: () => allow,
31
+ verifyToken: () => verifyToken
32
+ });
33
+ module.exports = __toCommonJS(authorization_exports);
34
+ var import_base = require("@akanjs/base");
35
+ var import_signal = require("@akanjs/signal");
36
+ var import_apollo = require("@nestjs/apollo");
37
+ var jwt = __toESM(require("jsonwebtoken"), 1);
38
+ const verifyToken = (secret, authorization) => {
39
+ const [type, token] = authorization?.split(" ") ?? [void 0, void 0];
40
+ if (!token || type !== "Bearer")
41
+ return import_signal.defaultAccount;
42
+ try {
43
+ const account = jwt.verify(token, secret);
44
+ if (account.appName !== import_base.baseEnv.appName || account.environment !== import_base.baseEnv.environment)
45
+ return import_signal.defaultAccount;
46
+ return {
47
+ __InternalArg__: "Account",
48
+ self: account.self && !account.self.removedAt ? account.self : void 0,
49
+ me: account.me && !account.me.removedAt ? account.me : void 0,
50
+ appName: account.appName,
51
+ environment: account.environment
52
+ };
53
+ } catch (e) {
54
+ return import_signal.defaultAccount;
55
+ }
56
+ };
57
+ const allow = (account, roles, userId) => {
58
+ if (!account)
59
+ throw new import_apollo.AuthenticationError("No Authentication Account");
60
+ for (const role of roles) {
61
+ if (role === "user" && account.self?.roles.includes("user"))
62
+ return true;
63
+ else if (role === "admin" && account.me?.roles.includes("admin"))
64
+ return true;
65
+ else if (role === "superAdmin" && account.me?.roles.includes("superAdmin"))
66
+ return true;
67
+ }
68
+ throw new import_apollo.AuthenticationError(
69
+ `No Authentication With Roles: ${roles.join(", ")}, Your roles are ${[
70
+ ...account.self?.roles ?? [],
71
+ ...account.me?.roles ?? []
72
+ ].join(", ")}${!account.self?.roles.length && !account.me?.roles.length ? " (No Roles)" : ""}`
73
+ );
74
+ };
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ allow,
78
+ verifyToken
79
+ });
@@ -1,48 +1,15 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var authorization_exports = {};
29
- __export(authorization_exports, {
30
- allow: () => allow,
31
- verifyToken: () => verifyToken
32
- });
33
- module.exports = __toCommonJS(authorization_exports);
34
- var import_base = require("@akanjs/base");
35
- var import_signal = require("@akanjs/signal");
36
- var import_apollo = require("@nestjs/apollo");
37
- var jwt = __toESM(require("jsonwebtoken"));
1
+ import { baseEnv } from "@akanjs/base";
2
+ import { defaultAccount } from "@akanjs/signal";
3
+ import { AuthenticationError } from "@nestjs/apollo";
4
+ import * as jwt from "jsonwebtoken";
38
5
  const verifyToken = (secret, authorization) => {
39
6
  const [type, token] = authorization?.split(" ") ?? [void 0, void 0];
40
7
  if (!token || type !== "Bearer")
41
- return import_signal.defaultAccount;
8
+ return defaultAccount;
42
9
  try {
43
10
  const account = jwt.verify(token, secret);
44
- if (account.appName !== import_base.baseEnv.appName || account.environment !== import_base.baseEnv.environment)
45
- return import_signal.defaultAccount;
11
+ if (account.appName !== baseEnv.appName || account.environment !== baseEnv.environment)
12
+ return defaultAccount;
46
13
  return {
47
14
  __InternalArg__: "Account",
48
15
  self: account.self && !account.self.removedAt ? account.self : void 0,
@@ -51,12 +18,12 @@ const verifyToken = (secret, authorization) => {
51
18
  environment: account.environment
52
19
  };
53
20
  } catch (e) {
54
- return import_signal.defaultAccount;
21
+ return defaultAccount;
55
22
  }
56
23
  };
57
24
  const allow = (account, roles, userId) => {
58
25
  if (!account)
59
- throw new import_apollo.AuthenticationError("No Authentication Account");
26
+ throw new AuthenticationError("No Authentication Account");
60
27
  for (const role of roles) {
61
28
  if (role === "user" && account.self?.roles.includes("user"))
62
29
  return true;
@@ -65,15 +32,14 @@ const allow = (account, roles, userId) => {
65
32
  else if (role === "superAdmin" && account.me?.roles.includes("superAdmin"))
66
33
  return true;
67
34
  }
68
- throw new import_apollo.AuthenticationError(
35
+ throw new AuthenticationError(
69
36
  `No Authentication With Roles: ${roles.join(", ")}, Your roles are ${[
70
37
  ...account.self?.roles ?? [],
71
38
  ...account.me?.roles ?? []
72
39
  ].join(", ")}${!account.self?.roles.length && !account.me?.roles.length ? " (No Roles)" : ""}`
73
40
  );
74
41
  };
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
42
+ export {
77
43
  allow,
78
44
  verifyToken
79
- });
45
+ };
@@ -0,0 +1,45 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __decorateClass = (decorators, target, key, kind) => {
19
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
21
+ if (decorator = decorators[i])
22
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
23
+ if (kind && result)
24
+ __defProp(target, key, result);
25
+ return result;
26
+ };
27
+ var cacheClient_exports = {};
28
+ __export(cacheClient_exports, {
29
+ CacheClient: () => CacheClient
30
+ });
31
+ module.exports = __toCommonJS(cacheClient_exports);
32
+ var import_common = require("@nestjs/common");
33
+ let CacheClient = class {
34
+ redis;
35
+ };
36
+ __decorateClass([
37
+ (0, import_common.Inject)("REDIS_CLIENT")
38
+ ], CacheClient.prototype, "redis", 2);
39
+ CacheClient = __decorateClass([
40
+ (0, import_common.Injectable)()
41
+ ], CacheClient);
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ CacheClient
45
+ });
@@ -1,20 +1,5 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
3
  var __decorateClass = (decorators, target, key, kind) => {
19
4
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -24,22 +9,16 @@ var __decorateClass = (decorators, target, key, kind) => {
24
9
  __defProp(target, key, result);
25
10
  return result;
26
11
  };
27
- var cacheClient_exports = {};
28
- __export(cacheClient_exports, {
29
- CacheClient: () => CacheClient
30
- });
31
- module.exports = __toCommonJS(cacheClient_exports);
32
- var import_common = require("@nestjs/common");
12
+ import { Inject, Injectable } from "@nestjs/common";
33
13
  let CacheClient = class {
34
14
  redis;
35
15
  };
36
16
  __decorateClass([
37
- (0, import_common.Inject)("REDIS_CLIENT")
17
+ Inject("REDIS_CLIENT")
38
18
  ], CacheClient.prototype, "redis", 2);
39
19
  CacheClient = __decorateClass([
40
- (0, import_common.Injectable)()
20
+ Injectable()
41
21
  ], CacheClient);
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
22
+ export {
44
23
  CacheClient
45
- });
24
+ };
@@ -0,0 +1,51 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __decorateClass = (decorators, target, key, kind) => {
19
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
21
+ if (decorator = decorators[i])
22
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
23
+ if (kind && result)
24
+ __defProp(target, key, result);
25
+ return result;
26
+ };
27
+ var databaseClient_exports = {};
28
+ __export(databaseClient_exports, {
29
+ DatabaseClient: () => DatabaseClient
30
+ });
31
+ module.exports = __toCommonJS(databaseClient_exports);
32
+ var import_common = require("@akanjs/common");
33
+ var import_common2 = require("@nestjs/common");
34
+ var import_mongoose = require("@nestjs/mongoose");
35
+ let DatabaseClient = class {
36
+ connection;
37
+ getModel(modelName) {
38
+ const model = this.connection.models[(0, import_common.capitalize)(modelName)];
39
+ return model;
40
+ }
41
+ };
42
+ __decorateClass([
43
+ (0, import_mongoose.InjectConnection)()
44
+ ], DatabaseClient.prototype, "connection", 2);
45
+ DatabaseClient = __decorateClass([
46
+ (0, import_common2.Injectable)()
47
+ ], DatabaseClient);
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ DatabaseClient
51
+ });
@@ -1,20 +1,5 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
3
  var __decorateClass = (decorators, target, key, kind) => {
19
4
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -24,28 +9,22 @@ var __decorateClass = (decorators, target, key, kind) => {
24
9
  __defProp(target, key, result);
25
10
  return result;
26
11
  };
27
- var databaseClient_exports = {};
28
- __export(databaseClient_exports, {
29
- DatabaseClient: () => DatabaseClient
30
- });
31
- module.exports = __toCommonJS(databaseClient_exports);
32
- var import_common = require("@akanjs/common");
33
- var import_common2 = require("@nestjs/common");
34
- var import_mongoose = require("@nestjs/mongoose");
12
+ import { capitalize } from "@akanjs/common";
13
+ import { Injectable } from "@nestjs/common";
14
+ import { InjectConnection } from "@nestjs/mongoose";
35
15
  let DatabaseClient = class {
36
16
  connection;
37
17
  getModel(modelName) {
38
- const model = this.connection.models[(0, import_common.capitalize)(modelName)];
18
+ const model = this.connection.models[capitalize(modelName)];
39
19
  return model;
40
20
  }
41
21
  };
42
22
  __decorateClass([
43
- (0, import_mongoose.InjectConnection)()
23
+ InjectConnection()
44
24
  ], DatabaseClient.prototype, "connection", 2);
45
25
  DatabaseClient = __decorateClass([
46
- (0, import_common2.Injectable)()
26
+ Injectable()
47
27
  ], DatabaseClient);
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
28
+ export {
50
29
  DatabaseClient
51
- });
30
+ };
@@ -1,5 +1,31 @@
1
- import "reflect-metadata";
2
- import { Cron as NestCron, Interval as NestInterval } from "@nestjs/schedule";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var decorators_exports = {};
19
+ __export(decorators_exports, {
20
+ Cache: () => Cache,
21
+ Cron: () => Cron,
22
+ Interval: () => Interval,
23
+ Transaction: () => Transaction,
24
+ Try: () => Try
25
+ });
26
+ module.exports = __toCommonJS(decorators_exports);
27
+ var import_reflect_metadata = require("reflect-metadata");
28
+ var import_schedule = require("@nestjs/schedule");
3
29
  const Try = () => {
4
30
  return function(target, key, descriptor) {
5
31
  const originMethod = descriptor.value;
@@ -35,7 +61,7 @@ const Cron = (cronTime, { lock = true, serverMode, enabled = true } = {}) => {
35
61
  if (!enabled)
36
62
  return;
37
63
  if (!serverMode || process.env.SERVER_MODE === "all" || serverMode === process.env.SERVER_MODE)
38
- NestCron(cronTime)(target, key, descriptor);
64
+ (0, import_schedule.Cron)(cronTime)(target, key, descriptor);
39
65
  };
40
66
  };
41
67
  const getIntervalMetaMap = (prototype) => {
@@ -71,7 +97,7 @@ const Interval = (ms, { lock = true, serverMode, enabled = true } = {}) => {
71
97
  if (!enabled)
72
98
  return;
73
99
  if (!serverMode || process.env.SERVER_MODE === "all" || serverMode === process.env.SERVER_MODE)
74
- NestInterval(ms)(target, key, descriptor);
100
+ (0, import_schedule.Interval)(ms)(target, key, descriptor);
75
101
  };
76
102
  };
77
103
  const Transaction = () => {
@@ -135,10 +161,11 @@ const Cache = (timeout = 1e3, getCacheKey) => {
135
161
  };
136
162
  };
137
163
  };
138
- export {
164
+ // Annotate the CommonJS export names for ESM import in node:
165
+ 0 && (module.exports = {
139
166
  Cache,
140
167
  Cron,
141
168
  Interval,
142
169
  Transaction,
143
170
  Try
144
- };
171
+ });
package/src/decorators.js CHANGED
@@ -1,31 +1,5 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var decorators_exports = {};
19
- __export(decorators_exports, {
20
- Cache: () => Cache,
21
- Cron: () => Cron,
22
- Interval: () => Interval,
23
- Transaction: () => Transaction,
24
- Try: () => Try
25
- });
26
- module.exports = __toCommonJS(decorators_exports);
27
- var import_reflect_metadata = require("reflect-metadata");
28
- var import_schedule = require("@nestjs/schedule");
1
+ import "reflect-metadata";
2
+ import { Cron as NestCron, Interval as NestInterval } from "@nestjs/schedule";
29
3
  const Try = () => {
30
4
  return function(target, key, descriptor) {
31
5
  const originMethod = descriptor.value;
@@ -61,7 +35,7 @@ const Cron = (cronTime, { lock = true, serverMode, enabled = true } = {}) => {
61
35
  if (!enabled)
62
36
  return;
63
37
  if (!serverMode || process.env.SERVER_MODE === "all" || serverMode === process.env.SERVER_MODE)
64
- (0, import_schedule.Cron)(cronTime)(target, key, descriptor);
38
+ NestCron(cronTime)(target, key, descriptor);
65
39
  };
66
40
  };
67
41
  const getIntervalMetaMap = (prototype) => {
@@ -97,7 +71,7 @@ const Interval = (ms, { lock = true, serverMode, enabled = true } = {}) => {
97
71
  if (!enabled)
98
72
  return;
99
73
  if (!serverMode || process.env.SERVER_MODE === "all" || serverMode === process.env.SERVER_MODE)
100
- (0, import_schedule.Interval)(ms)(target, key, descriptor);
74
+ NestInterval(ms)(target, key, descriptor);
101
75
  };
102
76
  };
103
77
  const Transaction = () => {
@@ -161,11 +135,10 @@ const Cache = (timeout = 1e3, getCacheKey) => {
161
135
  };
162
136
  };
163
137
  };
164
- // Annotate the CommonJS export names for ESM import in node:
165
- 0 && (module.exports = {
138
+ export {
166
139
  Cache,
167
140
  Cron,
168
141
  Interval,
169
142
  Transaction,
170
143
  Try
171
- });
144
+ };
@@ -1,5 +1,20 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
3
18
  var __decorateClass = (decorators, target, key, kind) => {
4
19
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
20
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -9,10 +24,15 @@ var __decorateClass = (decorators, target, key, kind) => {
9
24
  __defProp(target, key, result);
10
25
  return result;
11
26
  };
12
- import { Logger } from "@akanjs/common";
13
- import { Catch, HttpException } from "@nestjs/common";
27
+ var exceptions_exports = {};
28
+ __export(exceptions_exports, {
29
+ AllExceptionsFilter: () => AllExceptionsFilter
30
+ });
31
+ module.exports = __toCommonJS(exceptions_exports);
32
+ var import_common = require("@akanjs/common");
33
+ var import_common2 = require("@nestjs/common");
14
34
  let AllExceptionsFilter = class {
15
- logger = new Logger("Exception Filter");
35
+ logger = new import_common.Logger("Exception Filter");
16
36
  catch(exception, host) {
17
37
  if (host.getType() !== "http") {
18
38
  const gqlArgs = host.getArgByIndex(1);
@@ -32,13 +52,13 @@ ${exception.stack}`
32
52
  const req = ctx.getRequest();
33
53
  const reqType = req.method;
34
54
  const reqName = req.url;
35
- const status = exception instanceof HttpException ? exception.getStatus() : null;
55
+ const status = exception instanceof import_common2.HttpException ? exception.getStatus() : null;
36
56
  if (status) {
37
57
  res.status(status).json({
38
58
  statusCode: status,
39
59
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
40
60
  path: req.url,
41
- message: exception instanceof HttpException ? exception.getResponse() : exception.message
61
+ message: exception instanceof import_common2.HttpException ? exception.getResponse() : exception.message
42
62
  });
43
63
  this.logger.error(
44
64
  `Http Error: ${status}
@@ -50,8 +70,9 @@ ${exception.stack}`
50
70
  }
51
71
  };
52
72
  AllExceptionsFilter = __decorateClass([
53
- Catch()
73
+ (0, import_common2.Catch)()
54
74
  ], AllExceptionsFilter);
55
- export {
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
56
77
  AllExceptionsFilter
57
- };
78
+ });
package/src/exceptions.js CHANGED
@@ -1,20 +1,5 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
3
  var __decorateClass = (decorators, target, key, kind) => {
19
4
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -24,15 +9,10 @@ var __decorateClass = (decorators, target, key, kind) => {
24
9
  __defProp(target, key, result);
25
10
  return result;
26
11
  };
27
- var exceptions_exports = {};
28
- __export(exceptions_exports, {
29
- AllExceptionsFilter: () => AllExceptionsFilter
30
- });
31
- module.exports = __toCommonJS(exceptions_exports);
32
- var import_common = require("@akanjs/common");
33
- var import_common2 = require("@nestjs/common");
12
+ import { Logger } from "@akanjs/common";
13
+ import { Catch, HttpException } from "@nestjs/common";
34
14
  let AllExceptionsFilter = class {
35
- logger = new import_common.Logger("Exception Filter");
15
+ logger = new Logger("Exception Filter");
36
16
  catch(exception, host) {
37
17
  if (host.getType() !== "http") {
38
18
  const gqlArgs = host.getArgByIndex(1);
@@ -52,13 +32,13 @@ ${exception.stack}`
52
32
  const req = ctx.getRequest();
53
33
  const reqType = req.method;
54
34
  const reqName = req.url;
55
- const status = exception instanceof import_common2.HttpException ? exception.getStatus() : null;
35
+ const status = exception instanceof HttpException ? exception.getStatus() : null;
56
36
  if (status) {
57
37
  res.status(status).json({
58
38
  statusCode: status,
59
39
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
60
40
  path: req.url,
61
- message: exception instanceof import_common2.HttpException ? exception.getResponse() : exception.message
41
+ message: exception instanceof HttpException ? exception.getResponse() : exception.message
62
42
  });
63
43
  this.logger.error(
64
44
  `Http Error: ${status}
@@ -70,9 +50,8 @@ ${exception.stack}`
70
50
  }
71
51
  };
72
52
  AllExceptionsFilter = __decorateClass([
73
- (0, import_common2.Catch)()
53
+ Catch()
74
54
  ], AllExceptionsFilter);
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
55
+ export {
77
56
  AllExceptionsFilter
78
- });
57
+ };