@akanjs/nest 0.0.98 → 0.0.100
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/index.js +21 -1
- package/index.mjs +1 -0
- package/package.json +2 -2
- package/src/authGuards.js +56 -15
- package/src/{authGuards.cjs → authGuards.mjs} +15 -56
- package/src/authentication.js +67 -27
- package/src/authentication.mjs +82 -0
- package/src/authorization.js +46 -12
- package/src/authorization.mjs +45 -0
- package/src/cacheClient.js +26 -5
- package/src/cacheClient.mjs +24 -0
- package/src/databaseClient.js +29 -8
- package/src/databaseClient.mjs +30 -0
- package/src/decorators.js +33 -6
- package/src/{decorators.cjs → decorators.mjs} +6 -33
- package/src/exceptions.js +29 -8
- package/src/{exceptions.cjs → exceptions.mjs} +8 -29
- package/src/exporter.js +40 -3
- package/src/{exporter.cjs → exporter.mjs} +3 -40
- package/src/generateSecrets.js +43 -13
- package/src/{generateSecrets.cjs → generateSecrets.mjs} +13 -43
- package/src/index.js +72 -21
- package/src/index.mjs +22 -0
- package/src/interceptors.js +55 -36
- package/src/{interceptors.cjs → interceptors.mjs} +36 -55
- package/src/mongoose.js +44 -11
- package/src/mongoose.mjs +60 -0
- package/src/pipes.js +51 -22
- package/src/{pipes.cjs → pipes.mjs} +22 -51
- package/src/redis-io.adapter.js +35 -12
- package/src/redis-io.adapter.mjs +61 -0
- package/src/searchClient.js +28 -7
- package/src/{searchClient.cjs → searchClient.mjs} +7 -28
- package/src/sso.js +56 -24
- package/src/{sso.cjs → sso.mjs} +24 -56
- package/src/verifyPayment.js +37 -4
- package/src/verifyPayment.mjs +17 -0
- package/index.cjs +0 -21
- package/src/authentication.cjs +0 -122
- package/src/authorization.cjs +0 -79
- package/src/cacheClient.cjs +0 -45
- package/src/databaseClient.cjs +0 -51
- package/src/index.cjs +0 -73
- package/src/mongoose.cjs +0 -93
- package/src/redis-io.adapter.cjs +0 -84
- package/src/verifyPayment.cjs +0 -50
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { baseEnv } from "@akanjs/base";
|
|
2
|
+
import { defaultAccount } from "@akanjs/signal";
|
|
3
|
+
import { AuthenticationError } from "@nestjs/apollo";
|
|
4
|
+
import * as jwt from "jsonwebtoken";
|
|
5
|
+
const verifyToken = (secret, authorization) => {
|
|
6
|
+
const [type, token] = authorization?.split(" ") ?? [void 0, void 0];
|
|
7
|
+
if (!token || type !== "Bearer")
|
|
8
|
+
return defaultAccount;
|
|
9
|
+
try {
|
|
10
|
+
const account = jwt.verify(token, secret);
|
|
11
|
+
if (account.appName !== baseEnv.appName || account.environment !== baseEnv.environment)
|
|
12
|
+
return defaultAccount;
|
|
13
|
+
return {
|
|
14
|
+
__InternalArg__: "Account",
|
|
15
|
+
self: account.self && !account.self.removedAt ? account.self : void 0,
|
|
16
|
+
me: account.me && !account.me.removedAt ? account.me : void 0,
|
|
17
|
+
appName: account.appName,
|
|
18
|
+
environment: account.environment
|
|
19
|
+
};
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return defaultAccount;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const allow = (account, roles, userId) => {
|
|
25
|
+
if (!account)
|
|
26
|
+
throw new AuthenticationError("No Authentication Account");
|
|
27
|
+
for (const role of roles) {
|
|
28
|
+
if (role === "user" && account.self?.roles.includes("user"))
|
|
29
|
+
return true;
|
|
30
|
+
else if (role === "admin" && account.me?.roles.includes("admin"))
|
|
31
|
+
return true;
|
|
32
|
+
else if (role === "superAdmin" && account.me?.roles.includes("superAdmin"))
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
throw new AuthenticationError(
|
|
36
|
+
`No Authentication With Roles: ${roles.join(", ")}, Your roles are ${[
|
|
37
|
+
...account.self?.roles ?? [],
|
|
38
|
+
...account.me?.roles ?? []
|
|
39
|
+
].join(", ")}${!account.self?.roles.length && !account.me?.roles.length ? " (No Roles)" : ""}`
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
allow,
|
|
44
|
+
verifyToken
|
|
45
|
+
};
|
package/src/cacheClient.js
CHANGED
|
@@ -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,16 +24,22 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
24
|
__defProp(target, key, result);
|
|
10
25
|
return result;
|
|
11
26
|
};
|
|
12
|
-
|
|
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");
|
|
13
33
|
let CacheClient = class {
|
|
14
34
|
redis;
|
|
15
35
|
};
|
|
16
36
|
__decorateClass([
|
|
17
|
-
Inject("REDIS_CLIENT")
|
|
37
|
+
(0, import_common.Inject)("REDIS_CLIENT")
|
|
18
38
|
], CacheClient.prototype, "redis", 2);
|
|
19
39
|
CacheClient = __decorateClass([
|
|
20
|
-
Injectable()
|
|
40
|
+
(0, import_common.Injectable)()
|
|
21
41
|
], CacheClient);
|
|
22
|
-
export
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
23
44
|
CacheClient
|
|
24
|
-
};
|
|
45
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
13
|
+
let CacheClient = class {
|
|
14
|
+
redis;
|
|
15
|
+
};
|
|
16
|
+
__decorateClass([
|
|
17
|
+
Inject("REDIS_CLIENT")
|
|
18
|
+
], CacheClient.prototype, "redis", 2);
|
|
19
|
+
CacheClient = __decorateClass([
|
|
20
|
+
Injectable()
|
|
21
|
+
], CacheClient);
|
|
22
|
+
export {
|
|
23
|
+
CacheClient
|
|
24
|
+
};
|
package/src/databaseClient.js
CHANGED
|
@@ -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,22 +24,28 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
24
|
__defProp(target, key, result);
|
|
10
25
|
return result;
|
|
11
26
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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");
|
|
15
35
|
let DatabaseClient = class {
|
|
16
36
|
connection;
|
|
17
37
|
getModel(modelName) {
|
|
18
|
-
const model = this.connection.models[capitalize(modelName)];
|
|
38
|
+
const model = this.connection.models[(0, import_common.capitalize)(modelName)];
|
|
19
39
|
return model;
|
|
20
40
|
}
|
|
21
41
|
};
|
|
22
42
|
__decorateClass([
|
|
23
|
-
InjectConnection()
|
|
43
|
+
(0, import_mongoose.InjectConnection)()
|
|
24
44
|
], DatabaseClient.prototype, "connection", 2);
|
|
25
45
|
DatabaseClient = __decorateClass([
|
|
26
|
-
Injectable()
|
|
46
|
+
(0, import_common2.Injectable)()
|
|
27
47
|
], DatabaseClient);
|
|
28
|
-
export
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
29
50
|
DatabaseClient
|
|
30
|
-
};
|
|
51
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import { capitalize } from "@akanjs/common";
|
|
13
|
+
import { Injectable } from "@nestjs/common";
|
|
14
|
+
import { InjectConnection } from "@nestjs/mongoose";
|
|
15
|
+
let DatabaseClient = class {
|
|
16
|
+
connection;
|
|
17
|
+
getModel(modelName) {
|
|
18
|
+
const model = this.connection.models[capitalize(modelName)];
|
|
19
|
+
return model;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
__decorateClass([
|
|
23
|
+
InjectConnection()
|
|
24
|
+
], DatabaseClient.prototype, "connection", 2);
|
|
25
|
+
DatabaseClient = __decorateClass([
|
|
26
|
+
Injectable()
|
|
27
|
+
], DatabaseClient);
|
|
28
|
+
export {
|
|
29
|
+
DatabaseClient
|
|
30
|
+
};
|
package/src/decorators.js
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
});
|
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
(
|
|
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
|
-
(
|
|
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
|
-
|
|
165
|
-
0 && (module.exports = {
|
|
138
|
+
export {
|
|
166
139
|
Cache,
|
|
167
140
|
Cron,
|
|
168
141
|
Interval,
|
|
169
142
|
Transaction,
|
|
170
143
|
Try
|
|
171
|
-
}
|
|
144
|
+
};
|
package/src/exceptions.js
CHANGED
|
@@ -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
|
-
|
|
13
|
-
|
|
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
|
+
});
|
|
@@ -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
|
-
|
|
28
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
53
|
+
Catch()
|
|
74
54
|
], AllExceptionsFilter);
|
|
75
|
-
|
|
76
|
-
0 && (module.exports = {
|
|
55
|
+
export {
|
|
77
56
|
AllExceptionsFilter
|
|
78
|
-
}
|
|
57
|
+
};
|
package/src/exporter.js
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
|
|
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 exporter_exports = {};
|
|
29
|
+
__export(exporter_exports, {
|
|
30
|
+
FileSystem: () => FileSystem,
|
|
31
|
+
exportToCsv: () => exportToCsv,
|
|
32
|
+
exportToJson: () => exportToJson,
|
|
33
|
+
objPath: () => objPath,
|
|
34
|
+
readJson: () => readJson
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(exporter_exports);
|
|
37
|
+
var fs = __toESM(require("fs"));
|
|
2
38
|
const objPath = (o, p) => p.split(".").reduce((a, v) => a[v], o);
|
|
3
39
|
class FileSystem {
|
|
4
40
|
filename = "";
|
|
@@ -67,10 +103,11 @@ const exportToJson = (items, localPath) => {
|
|
|
67
103
|
fs.writeFileSync(localPath, JSON.stringify(items));
|
|
68
104
|
};
|
|
69
105
|
const readJson = (localPath) => JSON.parse(fs.readFileSync(localPath).toString("utf-8"));
|
|
70
|
-
export
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
71
108
|
FileSystem,
|
|
72
109
|
exportToCsv,
|
|
73
110
|
exportToJson,
|
|
74
111
|
objPath,
|
|
75
112
|
readJson
|
|
76
|
-
};
|
|
113
|
+
});
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
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 exporter_exports = {};
|
|
29
|
-
__export(exporter_exports, {
|
|
30
|
-
FileSystem: () => FileSystem,
|
|
31
|
-
exportToCsv: () => exportToCsv,
|
|
32
|
-
exportToJson: () => exportToJson,
|
|
33
|
-
objPath: () => objPath,
|
|
34
|
-
readJson: () => readJson
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(exporter_exports);
|
|
37
|
-
var fs = __toESM(require("fs"), 1);
|
|
1
|
+
import * as fs from "fs";
|
|
38
2
|
const objPath = (o, p) => p.split(".").reduce((a, v) => a[v], o);
|
|
39
3
|
class FileSystem {
|
|
40
4
|
filename = "";
|
|
@@ -103,11 +67,10 @@ const exportToJson = (items, localPath) => {
|
|
|
103
67
|
fs.writeFileSync(localPath, JSON.stringify(items));
|
|
104
68
|
};
|
|
105
69
|
const readJson = (localPath) => JSON.parse(fs.readFileSync(localPath).toString("utf-8"));
|
|
106
|
-
|
|
107
|
-
0 && (module.exports = {
|
|
70
|
+
export {
|
|
108
71
|
FileSystem,
|
|
109
72
|
exportToCsv,
|
|
110
73
|
exportToJson,
|
|
111
74
|
objPath,
|
|
112
75
|
readJson
|
|
113
|
-
}
|
|
76
|
+
};
|