@akanjs/nest 0.0.40 → 0.0.42
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.d.ts +1 -31
- package/index.js +2134 -21
- package/package.json +32 -2
- package/src/authGuards.d.ts +51 -7
- package/src/authentication.d.ts +13 -17
- package/src/authorization.d.ts +3 -9
- package/src/cacheClient.d.ts +2 -5
- package/src/databaseClient.d.ts +3 -7
- package/src/decorators.d.ts +8 -9
- package/src/exceptions.d.ts +2 -5
- package/src/exporter.d.ts +22 -2
- package/src/generateSecrets.d.ts +11 -13
- package/src/index.d.ts +18 -31
- package/src/interceptors.d.ts +7 -37
- package/src/mongoose.d.ts +1 -3
- package/src/pipes.d.ts +15 -19
- package/src/redis-io.adapter.d.ts +5 -7
- package/src/searchClient.d.ts +7 -14
- package/src/sso.d.ts +14 -19
- package/src/verifyPayment.d.ts +2 -3
- package/authGuards-BrXXzJa_.d.ts +0 -80
- package/baseEnv-Qb_Lg-a-.d.ts +0 -33
- package/exporter-BJ7Vr_DT.d.ts +0 -36
- package/signalDecorators-Bh7Aniud.d.ts +0 -121
- package/src/authGuards.js +0 -193
- package/src/authentication.js +0 -119
- package/src/authorization.js +0 -75
- package/src/cacheClient.js +0 -52
- package/src/databaseClient.js +0 -58
- package/src/decorators.js +0 -162
- package/src/exceptions.js +0 -76
- package/src/exporter.js +0 -117
- package/src/generateSecrets.js +0 -136
- package/src/index.js +0 -73
- package/src/interceptors.js +0 -176
- package/src/mongoose.js +0 -87
- package/src/pipes.js +0 -195
- package/src/redis-io.adapter.js +0 -96
- package/src/searchClient.js +0 -106
- package/src/sso.js +0 -250
- package/src/verifyPayment.js +0 -49
package/src/cacheClient.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var cacheClient_exports = {};
|
|
20
|
-
__export(cacheClient_exports, {
|
|
21
|
-
CacheClient: () => CacheClient
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(cacheClient_exports);
|
|
24
|
-
var import_common = require("@nestjs/common");
|
|
25
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
26
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
29
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
-
}
|
|
31
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
32
|
-
function _ts_metadata(k, v) {
|
|
33
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
34
|
-
}
|
|
35
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
36
|
-
class CacheClient {
|
|
37
|
-
static {
|
|
38
|
-
__name(this, "CacheClient");
|
|
39
|
-
}
|
|
40
|
-
redis;
|
|
41
|
-
}
|
|
42
|
-
_ts_decorate([
|
|
43
|
-
(0, import_common.Inject)("REDIS_CLIENT"),
|
|
44
|
-
_ts_metadata("design:type", typeof RedisClientType === "undefined" ? Object : RedisClientType)
|
|
45
|
-
], CacheClient.prototype, "redis", void 0);
|
|
46
|
-
CacheClient = _ts_decorate([
|
|
47
|
-
(0, import_common.Injectable)()
|
|
48
|
-
], CacheClient);
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
CacheClient
|
|
52
|
-
});
|
package/src/databaseClient.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var databaseClient_exports = {};
|
|
20
|
-
__export(databaseClient_exports, {
|
|
21
|
-
DatabaseClient: () => DatabaseClient
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(databaseClient_exports);
|
|
24
|
-
var import_common = require("@akanjs/common");
|
|
25
|
-
var import_common2 = require("@nestjs/common");
|
|
26
|
-
var import_mongoose = require("@nestjs/mongoose");
|
|
27
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
28
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
30
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
31
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
32
|
-
}
|
|
33
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
34
|
-
function _ts_metadata(k, v) {
|
|
35
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
36
|
-
}
|
|
37
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
38
|
-
class DatabaseClient {
|
|
39
|
-
static {
|
|
40
|
-
__name(this, "DatabaseClient");
|
|
41
|
-
}
|
|
42
|
-
connection;
|
|
43
|
-
getModel(modelName) {
|
|
44
|
-
const model = this.connection.models[(0, import_common.capitalize)(modelName)];
|
|
45
|
-
return model;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
_ts_decorate([
|
|
49
|
-
(0, import_mongoose.InjectConnection)(),
|
|
50
|
-
_ts_metadata("design:type", typeof Connection === "undefined" ? Object : Connection)
|
|
51
|
-
], DatabaseClient.prototype, "connection", void 0);
|
|
52
|
-
DatabaseClient = _ts_decorate([
|
|
53
|
-
(0, import_common2.Injectable)()
|
|
54
|
-
], DatabaseClient);
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
DatabaseClient
|
|
58
|
-
});
|
package/src/decorators.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var decorators_exports = {};
|
|
20
|
-
__export(decorators_exports, {
|
|
21
|
-
Cache: () => Cache,
|
|
22
|
-
Cron: () => Cron,
|
|
23
|
-
Interval: () => Interval,
|
|
24
|
-
Transaction: () => Transaction,
|
|
25
|
-
Try: () => Try
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(decorators_exports);
|
|
28
|
-
var import_reflect_metadata = require("reflect-metadata");
|
|
29
|
-
var import_schedule = require("@nestjs/schedule");
|
|
30
|
-
const Try = /* @__PURE__ */ __name(() => {
|
|
31
|
-
return function(target, key, descriptor) {
|
|
32
|
-
const originMethod = descriptor.value;
|
|
33
|
-
descriptor.value = async function(...args) {
|
|
34
|
-
try {
|
|
35
|
-
const result = await originMethod.apply(this, args);
|
|
36
|
-
return result;
|
|
37
|
-
} catch (e) {
|
|
38
|
-
this.logger?.warn(`${key} action error return: ${e}`);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
}, "Try");
|
|
43
|
-
const Cron = /* @__PURE__ */ __name((cronTime, { lock = true, serverMode, enabled = true } = {}) => {
|
|
44
|
-
return function(target, key, descriptor) {
|
|
45
|
-
const originMethod = descriptor.value;
|
|
46
|
-
let isRunning = false;
|
|
47
|
-
descriptor.value = async function(...args) {
|
|
48
|
-
if (lock && isRunning) return this.logger?.warn(`Cronjob-${key} is already running, skipped`);
|
|
49
|
-
try {
|
|
50
|
-
isRunning = true;
|
|
51
|
-
this.logger?.verbose(`Cron Job-${key} started`);
|
|
52
|
-
const res = await originMethod.apply(this, args);
|
|
53
|
-
this.logger?.verbose(`Cron Job-${key} finished`);
|
|
54
|
-
isRunning = false;
|
|
55
|
-
return res;
|
|
56
|
-
} catch (e) {
|
|
57
|
-
this.logger?.error(`Cron Job-${key} error return: ${e}`);
|
|
58
|
-
isRunning = false;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
if (!enabled) return;
|
|
62
|
-
if (!serverMode || process.env.SERVER_MODE === "all" || serverMode === process.env.SERVER_MODE) (0, import_schedule.Cron)(cronTime)(target, key, descriptor);
|
|
63
|
-
};
|
|
64
|
-
}, "Cron");
|
|
65
|
-
const getIntervalMetaMap = /* @__PURE__ */ __name((prototype) => {
|
|
66
|
-
return Reflect.getMetadata("serviceInterval", prototype) ?? /* @__PURE__ */ new Map();
|
|
67
|
-
}, "getIntervalMetaMap");
|
|
68
|
-
const setIntervalMetaMap = /* @__PURE__ */ __name((prototype, intervalMetaMap) => {
|
|
69
|
-
Reflect.defineMetadata("serviceInterval", intervalMetaMap, prototype);
|
|
70
|
-
}, "setIntervalMetaMap");
|
|
71
|
-
const Interval = /* @__PURE__ */ __name((ms, { lock = true, serverMode, enabled = true } = {}) => {
|
|
72
|
-
return function(target, key, descriptor) {
|
|
73
|
-
const intervalMetaMap = getIntervalMetaMap(target);
|
|
74
|
-
if (intervalMetaMap.has(key)) return descriptor;
|
|
75
|
-
intervalMetaMap.set(key, descriptor.value);
|
|
76
|
-
setIntervalMetaMap(target, intervalMetaMap);
|
|
77
|
-
const originMethod = descriptor.value;
|
|
78
|
-
let isRunning = false;
|
|
79
|
-
descriptor.value = async function(...args) {
|
|
80
|
-
if (lock && isRunning) return this.logger?.warn(`Cronjob-${key} is already running, skipped`);
|
|
81
|
-
try {
|
|
82
|
-
isRunning = true;
|
|
83
|
-
this.logger?.verbose(`Interval Job-${key} started`);
|
|
84
|
-
const res = await originMethod.apply(this, args);
|
|
85
|
-
this.logger?.verbose(`Interval Job-${key} finished`);
|
|
86
|
-
isRunning = false;
|
|
87
|
-
return res;
|
|
88
|
-
} catch (e) {
|
|
89
|
-
this.logger?.error(`Cronjob-${key} error return: ${e}`);
|
|
90
|
-
isRunning = false;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
if (!enabled) return;
|
|
94
|
-
if (!serverMode || process.env.SERVER_MODE === "all" || serverMode === process.env.SERVER_MODE) (0, import_schedule.Interval)(ms)(target, key, descriptor);
|
|
95
|
-
};
|
|
96
|
-
}, "Interval");
|
|
97
|
-
const Transaction = /* @__PURE__ */ __name(() => {
|
|
98
|
-
return function(target, key, descriptor) {
|
|
99
|
-
const originMethod = descriptor.value;
|
|
100
|
-
descriptor.value = function(...args) {
|
|
101
|
-
if (!this.connection) throw new Error(`No Connection in function ${key}`);
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
this.connection.transaction(async () => {
|
|
104
|
-
const res = await originMethod.apply(this, args);
|
|
105
|
-
resolve(res);
|
|
106
|
-
}).catch(reject);
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
return descriptor;
|
|
110
|
-
};
|
|
111
|
-
}, "Transaction");
|
|
112
|
-
const Cache = /* @__PURE__ */ __name((timeout = 1e3, getCacheKey) => {
|
|
113
|
-
return function(target, key, descriptor) {
|
|
114
|
-
const originMethod = descriptor.value;
|
|
115
|
-
const cacheMap = /* @__PURE__ */ new Map();
|
|
116
|
-
const timerMap = /* @__PURE__ */ new Map();
|
|
117
|
-
descriptor.value = async function(...args) {
|
|
118
|
-
const classType = this.__model ? "doc" : this.__databaseModel ? "service" : "class";
|
|
119
|
-
const model = this.__model ?? this.__databaseModel?.__model;
|
|
120
|
-
const cache = this.__cache ?? this.__databaseModel?.__cache;
|
|
121
|
-
const getCacheKeyFn = getCacheKey ?? JSON.stringify;
|
|
122
|
-
const cacheKey = `${classType}:${model.modelName}:${key}:${getCacheKeyFn(...args)}`;
|
|
123
|
-
const getCache = /* @__PURE__ */ __name(async (cacheKey2) => {
|
|
124
|
-
if (classType === "class") return cacheMap.get(cacheKey2);
|
|
125
|
-
const cached = await cache.get(cacheKey2);
|
|
126
|
-
if (cached) return JSON.parse(cached);
|
|
127
|
-
return null;
|
|
128
|
-
}, "getCache");
|
|
129
|
-
const setCache = /* @__PURE__ */ __name(async (cacheKey2, value) => {
|
|
130
|
-
if (classType === "class") {
|
|
131
|
-
const existingTimer = timerMap.get(cacheKey2);
|
|
132
|
-
if (existingTimer) clearTimeout(existingTimer);
|
|
133
|
-
cacheMap.set(cacheKey2, value);
|
|
134
|
-
const timer = setTimeout(() => {
|
|
135
|
-
cacheMap.delete(cacheKey2);
|
|
136
|
-
timerMap.delete(cacheKey2);
|
|
137
|
-
}, timeout);
|
|
138
|
-
timerMap.set(cacheKey2, timer);
|
|
139
|
-
} else await cache.set(cacheKey2, JSON.stringify(value), {
|
|
140
|
-
PX: timeout
|
|
141
|
-
});
|
|
142
|
-
}, "setCache");
|
|
143
|
-
const cachedData = await getCache(cacheKey);
|
|
144
|
-
if (cachedData) {
|
|
145
|
-
this.logger?.trace(`${model.modelName} cache hit: ${cacheKey}`);
|
|
146
|
-
return cachedData;
|
|
147
|
-
}
|
|
148
|
-
const result = await originMethod.apply(this, args);
|
|
149
|
-
await setCache(cacheKey, result);
|
|
150
|
-
this.logger?.trace(`${model.modelName} cache set: ${cacheKey}`);
|
|
151
|
-
return result;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
}, "Cache");
|
|
155
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
156
|
-
0 && (module.exports = {
|
|
157
|
-
Cache,
|
|
158
|
-
Cron,
|
|
159
|
-
Interval,
|
|
160
|
-
Transaction,
|
|
161
|
-
Try
|
|
162
|
-
});
|
package/src/exceptions.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var exceptions_exports = {};
|
|
20
|
-
__export(exceptions_exports, {
|
|
21
|
-
AllExceptionsFilter: () => AllExceptionsFilter
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(exceptions_exports);
|
|
24
|
-
var import_common = require("@akanjs/common");
|
|
25
|
-
var import_common2 = require("@nestjs/common");
|
|
26
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
27
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
-
}
|
|
32
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
33
|
-
class AllExceptionsFilter {
|
|
34
|
-
static {
|
|
35
|
-
__name(this, "AllExceptionsFilter");
|
|
36
|
-
}
|
|
37
|
-
logger = new import_common.Logger("Exception Filter");
|
|
38
|
-
catch(exception, host) {
|
|
39
|
-
if (host.getType() !== "http") {
|
|
40
|
-
const gqlArgs = host.getArgByIndex(1);
|
|
41
|
-
const gqlReq = host.getArgByIndex(3);
|
|
42
|
-
const reqType2 = gqlReq?.parentType?.name ?? "unknown";
|
|
43
|
-
const reqName2 = gqlReq?.fieldName ?? "unknown";
|
|
44
|
-
this.logger.error(`GraphQL Error
|
|
45
|
-
Request: ${reqType2}-${reqName2}
|
|
46
|
-
Args: ${JSON.stringify(gqlArgs, null, 2)}
|
|
47
|
-
${exception.stack}`);
|
|
48
|
-
throw exception;
|
|
49
|
-
}
|
|
50
|
-
const ctx = host.switchToHttp();
|
|
51
|
-
const res = ctx.getResponse();
|
|
52
|
-
const req = ctx.getRequest();
|
|
53
|
-
const reqType = req.method;
|
|
54
|
-
const reqName = req.url;
|
|
55
|
-
const status = exception instanceof import_common2.HttpException ? exception.getStatus() : null;
|
|
56
|
-
if (status) {
|
|
57
|
-
res.status(status).json({
|
|
58
|
-
statusCode: status,
|
|
59
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
60
|
-
path: req.url,
|
|
61
|
-
message: exception instanceof import_common2.HttpException ? exception.getResponse() : exception.message
|
|
62
|
-
});
|
|
63
|
-
this.logger.error(`Http Error: ${status}
|
|
64
|
-
Request: ${reqType}-${reqName}
|
|
65
|
-
Body: ${JSON.stringify(req.body, null, 2)}
|
|
66
|
-
${exception.stack}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
AllExceptionsFilter = _ts_decorate([
|
|
71
|
-
(0, import_common2.Catch)()
|
|
72
|
-
], AllExceptionsFilter);
|
|
73
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 && (module.exports = {
|
|
75
|
-
AllExceptionsFilter
|
|
76
|
-
});
|
package/src/exporter.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var exporter_exports = {};
|
|
30
|
-
__export(exporter_exports, {
|
|
31
|
-
FileSystem: () => FileSystem,
|
|
32
|
-
exportToCsv: () => exportToCsv,
|
|
33
|
-
exportToJson: () => exportToJson,
|
|
34
|
-
objPath: () => objPath,
|
|
35
|
-
readJson: () => readJson
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(exporter_exports);
|
|
38
|
-
var fs = __toESM(require("fs"));
|
|
39
|
-
const objPath = /* @__PURE__ */ __name((o, p) => p.split(".").reduce((a, v) => a[v], o), "objPath");
|
|
40
|
-
class FileSystem {
|
|
41
|
-
static {
|
|
42
|
-
__name(this, "FileSystem");
|
|
43
|
-
}
|
|
44
|
-
filename = "";
|
|
45
|
-
dirname = "./";
|
|
46
|
-
writeStream;
|
|
47
|
-
constructor(dirname = "./", filename = "") {
|
|
48
|
-
this.dirname = dirname;
|
|
49
|
-
this.filename = filename;
|
|
50
|
-
}
|
|
51
|
-
async init() {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
fs.mkdirSync(this.dirname, {
|
|
54
|
-
recursive: true
|
|
55
|
-
});
|
|
56
|
-
const writeStream = fs.createWriteStream(`${this.dirname}/${this.filename}.csv`);
|
|
57
|
-
if (!writeStream) {
|
|
58
|
-
reject(new Error("No WriteStream"));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
writeStream.once(`open`, () => {
|
|
62
|
-
this.writeStream = writeStream;
|
|
63
|
-
resolve(writeStream);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
write(body) {
|
|
68
|
-
if (!this.writeStream) throw new Error("no write stream");
|
|
69
|
-
return this.writeStream.write(`${body.replace(/\n/g, "")}
|
|
70
|
-
`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const exportToCsv = /* @__PURE__ */ __name(async ({ items, path, fields, delimiter, options }) => {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
const dirs = path.split("/");
|
|
76
|
-
if (dirs.length > 1) {
|
|
77
|
-
const dirname = dirs.slice(-1).join("/");
|
|
78
|
-
if (!fs.existsSync(dirname)) fs.mkdirSync(dirname, {
|
|
79
|
-
recursive: true
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (!fields) throw new Error("Fields Required");
|
|
83
|
-
const writeStream = !options?.append && fs.createWriteStream(path);
|
|
84
|
-
const header = fields.reduce((acc, cur) => acc + (delimiter ?? `,`) + cur) + `
|
|
85
|
-
`;
|
|
86
|
-
if (!writeStream) {
|
|
87
|
-
reject(new Error("No WriteStream"));
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
writeStream.once(`open`, () => {
|
|
91
|
-
writeStream.write(header);
|
|
92
|
-
for (const item of items) {
|
|
93
|
-
const data = fields.map((field) => objPath(item, field) ?? null).map((field) => String(field).replace(/\n/g, "").replace(/,/g, ""));
|
|
94
|
-
const body = data.reduce((acc, cur) => acc + (delimiter ?? `,`) + cur) + `
|
|
95
|
-
`;
|
|
96
|
-
if (options?.append) fs.appendFileSync(path, body);
|
|
97
|
-
}
|
|
98
|
-
resolve();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}, "exportToCsv");
|
|
102
|
-
const exportToJson = /* @__PURE__ */ __name((items, localPath) => {
|
|
103
|
-
const dirname = localPath.split("/").slice(0, -1).join("/");
|
|
104
|
-
if (!fs.existsSync(dirname)) fs.mkdirSync(dirname, {
|
|
105
|
-
recursive: true
|
|
106
|
-
});
|
|
107
|
-
fs.writeFileSync(localPath, JSON.stringify(items));
|
|
108
|
-
}, "exportToJson");
|
|
109
|
-
const readJson = /* @__PURE__ */ __name((localPath) => JSON.parse(fs.readFileSync(localPath).toString("utf-8")), "readJson");
|
|
110
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
-
0 && (module.exports = {
|
|
112
|
-
FileSystem,
|
|
113
|
-
exportToCsv,
|
|
114
|
-
exportToJson,
|
|
115
|
-
objPath,
|
|
116
|
-
readJson
|
|
117
|
-
});
|
package/src/generateSecrets.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var generateSecrets_exports = {};
|
|
20
|
-
__export(generateSecrets_exports, {
|
|
21
|
-
SALT_ROUNDS: () => SALT_ROUNDS,
|
|
22
|
-
generateAeskey: () => generateAeskey,
|
|
23
|
-
generateHost: () => generateHost,
|
|
24
|
-
generateJwtSecret: () => generateJwtSecret,
|
|
25
|
-
generateMeiliKey: () => generateMeiliKey,
|
|
26
|
-
generateMeiliUri: () => generateMeiliUri,
|
|
27
|
-
generateMongoUri: () => generateMongoUri,
|
|
28
|
-
generateRedisUri: () => generateRedisUri
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(generateSecrets_exports);
|
|
31
|
-
var import_base = require("@akanjs/base");
|
|
32
|
-
var import_crypto = require("crypto");
|
|
33
|
-
var import_tunnel_ssh = require("tunnel-ssh");
|
|
34
|
-
const generateHexStringFromSeed = /* @__PURE__ */ __name((seed, length = 256) => {
|
|
35
|
-
let hexString = "";
|
|
36
|
-
let currentSeed = seed;
|
|
37
|
-
while (hexString.length < length * 2) {
|
|
38
|
-
const hash = (0, import_crypto.createHash)("sha256").update(currentSeed).digest("hex");
|
|
39
|
-
hexString += hash;
|
|
40
|
-
currentSeed = hash;
|
|
41
|
-
}
|
|
42
|
-
return hexString.substring(0, length * 2);
|
|
43
|
-
}, "generateHexStringFromSeed");
|
|
44
|
-
const generateJwtSecret = /* @__PURE__ */ __name((appName, environment) => {
|
|
45
|
-
const seed = `${appName}-${environment}-jwt-secret`;
|
|
46
|
-
return generateHexStringFromSeed(seed);
|
|
47
|
-
}, "generateJwtSecret");
|
|
48
|
-
const generateAeskey = /* @__PURE__ */ __name((appName, environment) => {
|
|
49
|
-
const seed = `${appName}-${environment}-aes-key`;
|
|
50
|
-
return (0, import_crypto.createHash)("sha256").update(seed).digest("hex");
|
|
51
|
-
}, "generateAeskey");
|
|
52
|
-
const DEFAULT_CLOUD_PORT = 3e4;
|
|
53
|
-
const getEnvironmentPort = /* @__PURE__ */ __name((environment) => environment === "main" ? 2e3 : environment === "develop" ? 1e3 : environment === "debug" ? 0 : 0, "getEnvironmentPort");
|
|
54
|
-
const getServicePort = /* @__PURE__ */ __name((appCode, service) => (service === "redis" ? 300 : service === "mongo" ? 400 : 500) + appCode % 10 * 10 + (appCode >= 10 ? 5 : 0), "getServicePort");
|
|
55
|
-
const createDatabaseTunnel = /* @__PURE__ */ __name(async ({ appName, environment, type, port, sshOptions = {
|
|
56
|
-
host: `${appName}-${environment}.${import_base.baseEnv.serveDomain}`,
|
|
57
|
-
port: 32767,
|
|
58
|
-
username: import_base.baseEnv.tunnelUsername,
|
|
59
|
-
password: import_base.baseEnv.tunnelPassword
|
|
60
|
-
} }) => {
|
|
61
|
-
const tunnelOptions = {
|
|
62
|
-
autoClose: true,
|
|
63
|
-
reconnectOnError: false
|
|
64
|
-
};
|
|
65
|
-
const serverOptions = {
|
|
66
|
-
port
|
|
67
|
-
};
|
|
68
|
-
const forwardOptions = {
|
|
69
|
-
srcAddr: "0.0.0.0",
|
|
70
|
-
srcPort: port,
|
|
71
|
-
dstAddr: `${type}-0.${type}-svc.${appName}-${environment}`,
|
|
72
|
-
dstPort: type === "mongo" ? 27017 : type === "redis" ? 6379 : 7700
|
|
73
|
-
};
|
|
74
|
-
const [server, client] = await (0, import_tunnel_ssh.createTunnel)(tunnelOptions, serverOptions, sshOptions, forwardOptions);
|
|
75
|
-
return `localhost:${port}`;
|
|
76
|
-
}, "createDatabaseTunnel");
|
|
77
|
-
const generateRedisUri = /* @__PURE__ */ __name(async ({ appName, appCode, environment, operationMode, sshOptions }) => {
|
|
78
|
-
if (process.env.REDIS_URI) return process.env.REDIS_URI;
|
|
79
|
-
const port = operationMode === "local" ? DEFAULT_CLOUD_PORT + getEnvironmentPort(environment) + getServicePort(appCode, "redis") : 6379;
|
|
80
|
-
const url = operationMode === "cloud" ? `redis-svc.${appName}-${environment}.svc.cluster.local` : operationMode === "local" ? await createDatabaseTunnel({
|
|
81
|
-
appName,
|
|
82
|
-
environment,
|
|
83
|
-
type: "redis",
|
|
84
|
-
port,
|
|
85
|
-
sshOptions
|
|
86
|
-
}) : "localhost:6379";
|
|
87
|
-
const uri = `redis://${url}`;
|
|
88
|
-
return uri;
|
|
89
|
-
}, "generateRedisUri");
|
|
90
|
-
const generateMongoUri = /* @__PURE__ */ __name(async ({ appName, appCode, environment, operationMode, username = `${appName}-${environment}-mongo-user`, password, sshOptions }) => {
|
|
91
|
-
if (process.env.MONGO_URI) return process.env.MONGO_URI;
|
|
92
|
-
const record = operationMode === "cloud" ? "mongodb+srv" : "mongodb";
|
|
93
|
-
const port = operationMode === "local" ? DEFAULT_CLOUD_PORT + getEnvironmentPort(environment) + getServicePort(appCode, "mongo") : 27017;
|
|
94
|
-
const url = operationMode === "cloud" ? `mongo-svc.${appName}-${environment}.svc.cluster.local` : operationMode === "local" ? await createDatabaseTunnel({
|
|
95
|
-
appName,
|
|
96
|
-
environment,
|
|
97
|
-
type: "mongo",
|
|
98
|
-
port,
|
|
99
|
-
sshOptions
|
|
100
|
-
}) : "localhost:27017";
|
|
101
|
-
const usernameEncoded = password ? encodeURIComponent(username) : null;
|
|
102
|
-
const passwordEncoded = password ? encodeURIComponent(password) : null;
|
|
103
|
-
const dbName = `${appName}-${environment}`;
|
|
104
|
-
const directConnection = operationMode === "cloud" ? false : true;
|
|
105
|
-
const authInfo = usernameEncoded ? `${usernameEncoded}:${passwordEncoded}@` : "";
|
|
106
|
-
const uri = `${record}://${authInfo}${url}/${dbName}?authSource=${dbName}&readPreference=primary&ssl=false&retryWrites=true&directConnection=${directConnection}`;
|
|
107
|
-
return uri;
|
|
108
|
-
}, "generateMongoUri");
|
|
109
|
-
const generateMeiliUri = /* @__PURE__ */ __name(({ appName, appCode, environment, operationMode }) => {
|
|
110
|
-
if (process.env.MEILI_URI) return process.env.MEILI_URI;
|
|
111
|
-
const protocol = operationMode === "local" ? "https" : "http";
|
|
112
|
-
const url = operationMode === "cloud" ? `meili-0.meili-svc.${appName}-${environment}.svc.cluster.local:7700` : operationMode === "local" ? `${appName}-${environment}.${import_base.baseEnv.serveDomain}/search` : "localhost:7700";
|
|
113
|
-
const uri = `${protocol}://${url}`;
|
|
114
|
-
return uri;
|
|
115
|
-
}, "generateMeiliUri");
|
|
116
|
-
const SALT_ROUNDS = 11;
|
|
117
|
-
const generateHost = /* @__PURE__ */ __name((env) => {
|
|
118
|
-
if (process.env.HOST_NAME) return process.env.HOST_NAME;
|
|
119
|
-
else if (env.hostname) return env.hostname;
|
|
120
|
-
else if (env.operationMode === "local") return "localhost";
|
|
121
|
-
else return `${env.appName}-${env.environment}.${import_base.baseEnv.serveDomain}`;
|
|
122
|
-
}, "generateHost");
|
|
123
|
-
const generateMeiliKey = /* @__PURE__ */ __name(({ appName, environment }) => {
|
|
124
|
-
return `meilisearch-key-${appName}-${environment}`;
|
|
125
|
-
}, "generateMeiliKey");
|
|
126
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
-
0 && (module.exports = {
|
|
128
|
-
SALT_ROUNDS,
|
|
129
|
-
generateAeskey,
|
|
130
|
-
generateHost,
|
|
131
|
-
generateJwtSecret,
|
|
132
|
-
generateMeiliKey,
|
|
133
|
-
generateMeiliUri,
|
|
134
|
-
generateMongoUri,
|
|
135
|
-
generateRedisUri
|
|
136
|
-
});
|
package/src/index.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var src_exports = {};
|
|
30
|
-
__export(src_exports, {
|
|
31
|
-
Exporter: () => Exporter,
|
|
32
|
-
guards: () => guards
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(src_exports);
|
|
35
|
-
__reExport(src_exports, require("./authorization"), module.exports);
|
|
36
|
-
__reExport(src_exports, require("./authGuards"), module.exports);
|
|
37
|
-
var guards = __toESM(require("./authGuards"));
|
|
38
|
-
__reExport(src_exports, require("./authentication"), module.exports);
|
|
39
|
-
__reExport(src_exports, require("./interceptors"), module.exports);
|
|
40
|
-
__reExport(src_exports, require("./redis-io.adapter"), module.exports);
|
|
41
|
-
__reExport(src_exports, require("./pipes"), module.exports);
|
|
42
|
-
var Exporter = __toESM(require("./exporter"));
|
|
43
|
-
__reExport(src_exports, require("./exporter"), module.exports);
|
|
44
|
-
__reExport(src_exports, require("./verifyPayment"), module.exports);
|
|
45
|
-
__reExport(src_exports, require("./sso"), module.exports);
|
|
46
|
-
__reExport(src_exports, require("./exceptions"), module.exports);
|
|
47
|
-
__reExport(src_exports, require("./generateSecrets"), module.exports);
|
|
48
|
-
__reExport(src_exports, require("./mongoose"), module.exports);
|
|
49
|
-
__reExport(src_exports, require("./searchClient"), module.exports);
|
|
50
|
-
__reExport(src_exports, require("./cacheClient"), module.exports);
|
|
51
|
-
__reExport(src_exports, require("./databaseClient"), module.exports);
|
|
52
|
-
__reExport(src_exports, require("./decorators"), module.exports);
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
Exporter,
|
|
56
|
-
guards,
|
|
57
|
-
...require("./authorization"),
|
|
58
|
-
...require("./authGuards"),
|
|
59
|
-
...require("./authentication"),
|
|
60
|
-
...require("./interceptors"),
|
|
61
|
-
...require("./redis-io.adapter"),
|
|
62
|
-
...require("./pipes"),
|
|
63
|
-
...require("./exporter"),
|
|
64
|
-
...require("./verifyPayment"),
|
|
65
|
-
...require("./sso"),
|
|
66
|
-
...require("./exceptions"),
|
|
67
|
-
...require("./generateSecrets"),
|
|
68
|
-
...require("./mongoose"),
|
|
69
|
-
...require("./searchClient"),
|
|
70
|
-
...require("./cacheClient"),
|
|
71
|
-
...require("./databaseClient"),
|
|
72
|
-
...require("./decorators")
|
|
73
|
-
});
|