@futdevpro/nts-dynamo 1.3.47 → 1.3.49
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/lib/_constants/dynamobe-global.settings.js +6 -4
- package/lib/_enums/data-model-type.enum.js +5 -3
- package/lib/_enums/dynamobe-data-service-function.enum.js +5 -3
- package/lib/_enums/dynamobe-route-security.enum.js +5 -3
- package/lib/_enums/http/http-call-type.enum.js +5 -3
- package/lib/_enums/http/http-response-type.enum.js +5 -3
- package/lib/_enums/index.js +10 -8
- package/lib/_enums/log-style.enum.js +5 -3
- package/lib/_enums/predefined-data-types.enum.js +5 -3
- package/lib/_models/dynamobe-api-call-params.js +7 -3
- package/lib/_models/dynamobe-app-params.js +5 -2
- package/lib/_models/dynamobe-data-model-params.js +5 -2
- package/lib/_models/dynamobe-endpoint-control.js +23 -20
- package/lib/_models/dynamobe-global-settings.js +2 -1
- package/lib/_models/fullstack-models/control-models/daily-usage-data.js +5 -2
- package/lib/_models/fullstack-models/control-models/dynamobe-data-property-params.js +7 -4
- package/lib/_models/fullstack-models/control-models/dynamobe-error.js +5 -2
- package/lib/_models/fullstack-models/control-models/geo-ip-location.js +2 -1
- package/lib/_models/fullstack-models/control-models/usage-action.js +5 -2
- package/lib/_models/fullstack-models/control-models/usage-data.js +5 -2
- package/lib/_models/fullstack-models/data-models/custom-data.js +7 -4
- package/lib/_models/fullstack-models/data-models/metadata.js +5 -2
- package/lib/_models/fullstack-models/data-models/usage-session.js +7 -4
- package/lib/_models/index.js +17 -15
- package/lib/_modules/index.js +7 -5
- package/lib/_modules/test-route/custom-data.service.js +9 -6
- package/lib/_modules/test-route/test-controller.js +33 -30
- package/lib/_modules/usage-route/usage-controller.js +31 -28
- package/lib/_modules/usage-route/usage.service.js +24 -21
- package/lib/_services/dynamobe-api.service.js +29 -26
- package/lib/_services/dynamobe-app.js +12 -8
- package/lib/_services/dynamobe-auth.service.js +9 -6
- package/lib/_services/dynamobe-controller.service.js +6 -3
- package/lib/_services/dynamobe-data.service.js +32 -29
- package/lib/_services/dynamobe-db-service-collection.service.js +6 -3
- package/lib/_services/dynamobe-db.service.js +52 -49
- package/lib/_services/dynamobe-email-service-collection.service.js +6 -3
- package/lib/_services/dynamobe-email.service.js +18 -15
- package/lib/_services/dynamobe-global.service.js +8 -5
- package/lib/_services/dynamobe-routing-module.service.js +29 -26
- package/lib/_services/dynamobe-server.js +37 -34
- package/lib/_services/dynamobe-shared.service.js +34 -30
- package/lib/_services/dynamobe-singleton.service.js +5 -2
- package/lib/_services/index.js +17 -15
- package/lib/index.js +7 -5
- package/lib/tsconfig.tsbuildinfo +2 -12
- package/package.json +1 -1
- package/tsconfig.json +8 -8
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestController = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const http_call_type_enum_1 = require("../../_enums/http/http-call-type.enum");
|
|
6
|
+
const dynamobe_endpoint_control_1 = require("../../_models/dynamobe-endpoint-control");
|
|
7
|
+
const dynamobe_controller_service_1 = require("../../_services/dynamobe-controller.service");
|
|
8
|
+
const custom_data_service_1 = require("./custom-data.service");
|
|
9
|
+
class TestController extends dynamobe_controller_service_1.DynamoBEController {
|
|
7
10
|
static getInstance() {
|
|
8
11
|
return TestController.getSingletonInstance();
|
|
9
12
|
}
|
|
10
13
|
setupEndpoints() {
|
|
11
14
|
this.endpoints = [
|
|
12
15
|
// TESTS
|
|
13
|
-
new DynamoBEEndpointParams({
|
|
16
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
14
17
|
name: 'testGet',
|
|
15
|
-
type: HttpCallType.get,
|
|
18
|
+
type: http_call_type_enum_1.HttpCallType.get,
|
|
16
19
|
endpoint: '/test-get',
|
|
17
20
|
tasks: [
|
|
18
|
-
(req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
(req, res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
22
|
res.send({
|
|
20
23
|
url: req.url,
|
|
21
24
|
result: 'test-get call was successful!',
|
|
@@ -24,12 +27,12 @@ export class TestController extends DynamoBEController {
|
|
|
24
27
|
})
|
|
25
28
|
]
|
|
26
29
|
}),
|
|
27
|
-
new DynamoBEEndpointParams({
|
|
30
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
28
31
|
name: 'testPost',
|
|
29
|
-
type: HttpCallType.post,
|
|
32
|
+
type: http_call_type_enum_1.HttpCallType.post,
|
|
30
33
|
endpoint: '/test-post',
|
|
31
34
|
tasks: [
|
|
32
|
-
(req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
(req, res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
33
36
|
res.send({
|
|
34
37
|
url: req.url,
|
|
35
38
|
result: 'test-post call was successful!',
|
|
@@ -38,12 +41,12 @@ export class TestController extends DynamoBEController {
|
|
|
38
41
|
})
|
|
39
42
|
]
|
|
40
43
|
}),
|
|
41
|
-
new DynamoBEEndpointParams({
|
|
44
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
42
45
|
name: 'testPut',
|
|
43
|
-
type: HttpCallType.put,
|
|
46
|
+
type: http_call_type_enum_1.HttpCallType.put,
|
|
44
47
|
endpoint: '/test-put',
|
|
45
48
|
tasks: [
|
|
46
|
-
(req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
(req, res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
50
|
res.send({
|
|
48
51
|
url: req.url,
|
|
49
52
|
result: 'test-put call was successful!',
|
|
@@ -52,12 +55,12 @@ export class TestController extends DynamoBEController {
|
|
|
52
55
|
})
|
|
53
56
|
]
|
|
54
57
|
}),
|
|
55
|
-
new DynamoBEEndpointParams({
|
|
58
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
56
59
|
name: 'testPatch',
|
|
57
|
-
type: HttpCallType.patch,
|
|
60
|
+
type: http_call_type_enum_1.HttpCallType.patch,
|
|
58
61
|
endpoint: '/test-patch',
|
|
59
62
|
tasks: [
|
|
60
|
-
(req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
(req, res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
64
|
res.send({
|
|
62
65
|
url: req.url,
|
|
63
66
|
result: 'test-patch call was successful!',
|
|
@@ -66,12 +69,12 @@ export class TestController extends DynamoBEController {
|
|
|
66
69
|
})
|
|
67
70
|
]
|
|
68
71
|
}),
|
|
69
|
-
new DynamoBEEndpointParams({
|
|
72
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
70
73
|
name: 'testDelete',
|
|
71
|
-
type: HttpCallType.delete,
|
|
74
|
+
type: http_call_type_enum_1.HttpCallType.delete,
|
|
72
75
|
endpoint: '/test-delete',
|
|
73
76
|
tasks: [
|
|
74
|
-
(req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
(req, res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
75
78
|
res.send({
|
|
76
79
|
url: req.url,
|
|
77
80
|
result: 'test-delete call was successful!',
|
|
@@ -81,13 +84,13 @@ export class TestController extends DynamoBEController {
|
|
|
81
84
|
]
|
|
82
85
|
}),
|
|
83
86
|
// CUSTOM DATA
|
|
84
|
-
new DynamoBEEndpointParams({
|
|
87
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
85
88
|
name: 'getCustomData',
|
|
86
|
-
type: HttpCallType.get,
|
|
89
|
+
type: http_call_type_enum_1.HttpCallType.get,
|
|
87
90
|
endpoint: '/custom/get/:customId',
|
|
88
91
|
tasks: [
|
|
89
|
-
(req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
const customDataService = new CustomDataService({ _id: req.params.customId });
|
|
92
|
+
(req, res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const customDataService = new custom_data_service_1.CustomDataService({ _id: req.params.customId });
|
|
91
94
|
yield customDataService.getDataById();
|
|
92
95
|
res.send({
|
|
93
96
|
url: req.url,
|
|
@@ -98,13 +101,13 @@ export class TestController extends DynamoBEController {
|
|
|
98
101
|
})
|
|
99
102
|
]
|
|
100
103
|
}),
|
|
101
|
-
new DynamoBEEndpointParams({
|
|
104
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
102
105
|
name: 'modifyCustomData',
|
|
103
|
-
type: HttpCallType.post,
|
|
106
|
+
type: http_call_type_enum_1.HttpCallType.post,
|
|
104
107
|
endpoint: '/custom/post',
|
|
105
108
|
tasks: [
|
|
106
|
-
(req, res, issuer) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
const customDataService = new CustomDataService(req.body, issuer);
|
|
109
|
+
(req, res, issuer) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const customDataService = new custom_data_service_1.CustomDataService(req.body, issuer);
|
|
108
111
|
yield customDataService.saveData();
|
|
109
112
|
res.send({
|
|
110
113
|
url: req.url,
|
|
@@ -119,4 +122,4 @@ export class TestController extends DynamoBEController {
|
|
|
119
122
|
];
|
|
120
123
|
}
|
|
121
124
|
}
|
|
122
|
-
|
|
125
|
+
exports.TestController = TestController;
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsageController = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const http_call_type_enum_1 = require("../../_enums/http/http-call-type.enum");
|
|
6
|
+
const dynamobe_endpoint_control_1 = require("../../_models/dynamobe-endpoint-control");
|
|
7
|
+
const usage_session_1 = require("../../_models/fullstack-models/data-models/usage-session");
|
|
8
|
+
const dynamobe_controller_service_1 = require("../../_services/dynamobe-controller.service");
|
|
9
|
+
const dynamobe_global_service_1 = require("../../_services/dynamobe-global.service");
|
|
10
|
+
const usage_service_1 = require("./usage.service");
|
|
11
|
+
class UsageController extends dynamobe_controller_service_1.DynamoBEController {
|
|
9
12
|
static getInstance() {
|
|
10
13
|
return UsageController.getSingletonInstance();
|
|
11
14
|
}
|
|
12
15
|
setupEndpoints() {
|
|
13
|
-
this.authService = DBE_Global_S.getAuthService();
|
|
16
|
+
this.authService = dynamobe_global_service_1.DBE_Global_S.getAuthService();
|
|
14
17
|
this.endpoints = [
|
|
15
|
-
new DynamoBEEndpointParams({
|
|
18
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
16
19
|
name: 'newSession',
|
|
17
|
-
type: HttpCallType.get,
|
|
20
|
+
type: http_call_type_enum_1.HttpCallType.get,
|
|
18
21
|
endpoint: '/new-session',
|
|
19
22
|
tasks: [
|
|
20
|
-
(req, res, issuer) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const authService = DBE_Global_S.getAuthService();
|
|
23
|
+
(req, res, issuer) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const authService = dynamobe_global_service_1.DBE_Global_S.getAuthService();
|
|
22
25
|
const username = authService.getUsernameFromRequest(req);
|
|
23
|
-
const usageService = new UsageService({
|
|
24
|
-
usageSession: new DynamoUsageSession({
|
|
26
|
+
const usageService = new usage_service_1.UsageService({
|
|
27
|
+
usageSession: new usage_session_1.DynamoUsageSession({
|
|
25
28
|
sessionStart: new Date(),
|
|
26
29
|
issuer: username,
|
|
27
30
|
}),
|
|
@@ -33,14 +36,14 @@ export class UsageController extends DynamoBEController {
|
|
|
33
36
|
})
|
|
34
37
|
]
|
|
35
38
|
}),
|
|
36
|
-
new DynamoBEEndpointParams({
|
|
39
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
37
40
|
name: 'updateUsageData',
|
|
38
|
-
type: HttpCallType.post,
|
|
41
|
+
type: http_call_type_enum_1.HttpCallType.post,
|
|
39
42
|
endpoint: '/update/:sessionId',
|
|
40
43
|
logRequestsContent: false,
|
|
41
44
|
tasks: [
|
|
42
|
-
(req, res, issuer) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const usageService = new UsageService({
|
|
45
|
+
(req, res, issuer) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const usageService = new usage_service_1.UsageService({
|
|
44
47
|
usageSession: { _id: req.params.sessionId },
|
|
45
48
|
usageData: req.body,
|
|
46
49
|
issuer
|
|
@@ -50,14 +53,14 @@ export class UsageController extends DynamoBEController {
|
|
|
50
53
|
})
|
|
51
54
|
]
|
|
52
55
|
}),
|
|
53
|
-
new DynamoBEEndpointParams({
|
|
56
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
54
57
|
name: 'closeSession',
|
|
55
|
-
type: HttpCallType.get,
|
|
58
|
+
type: http_call_type_enum_1.HttpCallType.get,
|
|
56
59
|
endpoint: '/close-session/:sessionId',
|
|
57
60
|
preProcessess: [this.authService.authTokenPermAccUsageData],
|
|
58
61
|
tasks: [
|
|
59
|
-
(req, res, issuer) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const usageService = new UsageService({
|
|
62
|
+
(req, res, issuer) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const usageService = new usage_service_1.UsageService({
|
|
61
64
|
usageSession: { _id: req.params.sessionId },
|
|
62
65
|
issuer
|
|
63
66
|
});
|
|
@@ -66,14 +69,14 @@ export class UsageController extends DynamoBEController {
|
|
|
66
69
|
})
|
|
67
70
|
]
|
|
68
71
|
}),
|
|
69
|
-
new DynamoBEEndpointParams({
|
|
72
|
+
new dynamobe_endpoint_control_1.DynamoBEEndpointParams({
|
|
70
73
|
name: 'getAllUsageData',
|
|
71
|
-
type: HttpCallType.get,
|
|
74
|
+
type: http_call_type_enum_1.HttpCallType.get,
|
|
72
75
|
endpoint: '/get/all',
|
|
73
76
|
preProcessess: [this.authService.authTokenPermAccUsageData],
|
|
74
77
|
tasks: [
|
|
75
|
-
(req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const usageService = new UsageService();
|
|
78
|
+
(req, res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const usageService = new usage_service_1.UsageService();
|
|
77
80
|
yield usageService.getLastWeekUsage();
|
|
78
81
|
res.send(usageService.simplifiedDailyUsage);
|
|
79
82
|
})
|
|
@@ -82,4 +85,4 @@ export class UsageController extends DynamoBEController {
|
|
|
82
85
|
];
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
|
-
|
|
88
|
+
exports.UsageController = UsageController;
|
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsageService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const dynamobe_data_service_1 = require("../../_services/dynamobe-data.service");
|
|
6
|
+
const dynamobe_error_1 = require("../../_models/fullstack-models/control-models/dynamobe-error");
|
|
7
|
+
const dynamobe_shared_service_1 = require("../../_services/dynamobe-shared.service");
|
|
8
|
+
const daily_usage_data_1 = require("../../_models/fullstack-models/control-models/daily-usage-data");
|
|
9
|
+
const usage_session_1 = require("../../_models/fullstack-models/data-models/usage-session");
|
|
10
|
+
const dynamobe_global_service_1 = require("../../_services/dynamobe-global.service");
|
|
11
|
+
class UsageService extends dynamobe_data_service_1.DynamoBEDataService {
|
|
9
12
|
constructor(set) {
|
|
10
|
-
super(DBE_Global_S.getDBServiceCollection().usageDataDBService, new DynamoUsageSession(set === null || set === void 0 ? void 0 : set.usageSession), usageSessionModelParams, set === null || set === void 0 ? void 0 : set.issuer);
|
|
13
|
+
super(dynamobe_global_service_1.DBE_Global_S.getDBServiceCollection().usageDataDBService, new usage_session_1.DynamoUsageSession(set === null || set === void 0 ? void 0 : set.usageSession), usage_session_1.usageSessionModelParams, set === null || set === void 0 ? void 0 : set.issuer);
|
|
11
14
|
this.usageData = [];
|
|
12
15
|
this.simplifiedDailyUsage = [];
|
|
13
16
|
this.usageData = (set === null || set === void 0 ? void 0 : set.usageData) ? set === null || set === void 0 ? void 0 : set.usageData : [];
|
|
14
17
|
}
|
|
15
18
|
getLocationDataFromRequest(req) {
|
|
16
19
|
try {
|
|
17
|
-
this.data.address = DBE_Shared.getIpFromRequest(req);
|
|
18
|
-
this.data.locationData = DBE_Shared.getLocationDataByRequest(req);
|
|
20
|
+
this.data.address = dynamobe_shared_service_1.DBE_Shared.getIpFromRequest(req);
|
|
21
|
+
this.data.locationData = dynamobe_shared_service_1.DBE_Shared.getLocationDataByRequest(req);
|
|
19
22
|
/* console.log(`...getLocationDataFromRequest... ip: ${this.data.address}`, this.data.locationData); */
|
|
20
23
|
}
|
|
21
24
|
catch (error) {
|
|
22
|
-
throw new DynamoBEError({ status: 417, message: 'getLocationDataFromRequest was unsuccessful', error });
|
|
25
|
+
throw new dynamobe_error_1.DynamoBEError({ status: 417, message: 'getLocationDataFromRequest was unsuccessful', error });
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
getLastWeekUsage() {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
30
|
try {
|
|
28
31
|
yield this.dataDBService.find({
|
|
29
|
-
sessionStart: { $gte: DBE_Shared.oneWeekAgo() }
|
|
32
|
+
sessionStart: { $gte: dynamobe_shared_service_1.DBE_Shared.oneWeekAgo() }
|
|
30
33
|
}).then((res) => {
|
|
31
34
|
this.dataList = res;
|
|
32
35
|
});
|
|
@@ -38,7 +41,7 @@ export class UsageService extends DynamoBEDataService {
|
|
|
38
41
|
this.simplifiedDailyUsage[dateIndex].visitations.push(session);
|
|
39
42
|
}
|
|
40
43
|
else {
|
|
41
|
-
const newUsageSimple = new DailyUsageData({ date: session.date, visitations: [session] });
|
|
44
|
+
const newUsageSimple = new daily_usage_data_1.DailyUsageData({ date: session.date, visitations: [session] });
|
|
42
45
|
this.simplifiedDailyUsage.push(newUsageSimple);
|
|
43
46
|
dateIndex = this.simplifiedDailyUsage.length - 1;
|
|
44
47
|
}
|
|
@@ -60,12 +63,12 @@ export class UsageService extends DynamoBEDataService {
|
|
|
60
63
|
});
|
|
61
64
|
}
|
|
62
65
|
catch (error) {
|
|
63
|
-
throw new DynamoBEError({ status: 417, message: 'getDailyUsage was unsuccessful', error });
|
|
66
|
+
throw new dynamobe_error_1.DynamoBEError({ status: 417, message: 'getDailyUsage was unsuccessful', error });
|
|
64
67
|
}
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
updateUsageData(req) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
72
|
try {
|
|
70
73
|
yield this.getDataById();
|
|
71
74
|
this.data.usageData = this.usageData;
|
|
@@ -80,12 +83,12 @@ export class UsageService extends DynamoBEDataService {
|
|
|
80
83
|
yield this.saveData();
|
|
81
84
|
}
|
|
82
85
|
catch (error) {
|
|
83
|
-
throw new DynamoBEError({ status: 417, message: 'updateSessionData was unsuccessful', error });
|
|
86
|
+
throw new dynamobe_error_1.DynamoBEError({ status: 417, message: 'updateSessionData was unsuccessful', error });
|
|
84
87
|
}
|
|
85
88
|
});
|
|
86
89
|
}
|
|
87
90
|
closeSession(req) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
89
92
|
try {
|
|
90
93
|
yield this.getDataById();
|
|
91
94
|
this.data.sessionEnd = new Date();
|
|
@@ -99,9 +102,9 @@ export class UsageService extends DynamoBEDataService {
|
|
|
99
102
|
yield this.saveData();
|
|
100
103
|
}
|
|
101
104
|
catch (error) {
|
|
102
|
-
throw new DynamoBEError({ status: 417, message: 'closeSession was unsuccessful', error });
|
|
105
|
+
throw new dynamobe_error_1.DynamoBEError({ status: 417, message: 'closeSession was unsuccessful', error });
|
|
103
106
|
}
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
|
-
|
|
110
|
+
exports.UsageService = UsageService;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoBEApiService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Axios = tslib_1.__importStar(require("axios"));
|
|
6
|
+
const http_call_type_enum_1 = require("../_enums/http/http-call-type.enum");
|
|
7
|
+
const http_response_type_enum_1 = require("../_enums/http/http-response-type.enum");
|
|
8
|
+
const dynamobe_error_1 = require("../_models/fullstack-models/control-models/dynamobe-error");
|
|
9
|
+
const dynamobe_shared_service_1 = require("./dynamobe-shared.service");
|
|
10
|
+
class DynamoBEApiService {
|
|
8
11
|
static startApiCall(callParams, inputParams) {
|
|
9
12
|
var _a, _b, _c, _d;
|
|
10
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
14
|
try {
|
|
12
15
|
let a;
|
|
13
16
|
let url = callParams.baseUrl + callParams.endPoint;
|
|
@@ -18,7 +21,7 @@ export class DynamoBEApiService {
|
|
|
18
21
|
privateAxiosInstance.defaults.headers.common[headerKey] = callParams.httpOptions.headers[headerKey];
|
|
19
22
|
}
|
|
20
23
|
else {
|
|
21
|
-
DBE_Shared.logError('DYNAMOBE ERROR: \n missing header:', headerKey, '\n\n', new Error());
|
|
24
|
+
dynamobe_shared_service_1.DBE_Shared.logError('DYNAMOBE ERROR: \n missing header:', headerKey, '\n\n', new Error());
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
}
|
|
@@ -34,12 +37,12 @@ export class DynamoBEApiService {
|
|
|
34
37
|
url = url.replace(`{${pathParamKey}}`, inputParams.pathParams[pathParamKey]);
|
|
35
38
|
break;
|
|
36
39
|
default:
|
|
37
|
-
DBE_Shared.logError(`DYNAMOBE ERROR: \n wrong path param type: (${pathParamKey}): ${paramType} \n${inputParams.pathParams[pathParamKey]}\nMUST BE string or number\n\n`, new Error());
|
|
40
|
+
dynamobe_shared_service_1.DBE_Shared.logError(`DYNAMOBE ERROR: \n wrong path param type: (${pathParamKey}): ${paramType} \n${inputParams.pathParams[pathParamKey]}\nMUST BE string or number\n\n`, new Error());
|
|
38
41
|
break;
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
else {
|
|
42
|
-
DBE_Shared.logError('DYNAMOBE ERROR: \n missing pathParam:', pathParamKey, '\n\n', new Error());
|
|
45
|
+
dynamobe_shared_service_1.DBE_Shared.logError('DYNAMOBE ERROR: \n missing pathParam:', pathParamKey, '\n\n', new Error());
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
}
|
|
@@ -63,7 +66,7 @@ export class DynamoBEApiService {
|
|
|
63
66
|
callParams.httpOptions.params = httpParams;
|
|
64
67
|
} */
|
|
65
68
|
switch (callParams.type) {
|
|
66
|
-
case HttpCallType.get:
|
|
69
|
+
case http_call_type_enum_1.HttpCallType.get:
|
|
67
70
|
if (inputParams === null || inputParams === void 0 ? void 0 : inputParams.body) {
|
|
68
71
|
console.log('WARNING you cant send body in get calls');
|
|
69
72
|
}
|
|
@@ -72,7 +75,7 @@ export class DynamoBEApiService {
|
|
|
72
75
|
console.log(`${callParams.name} was successful`, res.data);
|
|
73
76
|
});
|
|
74
77
|
break;
|
|
75
|
-
case HttpCallType.delete:
|
|
78
|
+
case http_call_type_enum_1.HttpCallType.delete:
|
|
76
79
|
if (inputParams === null || inputParams === void 0 ? void 0 : inputParams.body) {
|
|
77
80
|
console.log('WARNING you cant send body in delete calls');
|
|
78
81
|
}
|
|
@@ -80,9 +83,9 @@ export class DynamoBEApiService {
|
|
|
80
83
|
console.log(`${callParams.name} was successful`, res.data);
|
|
81
84
|
});
|
|
82
85
|
break;
|
|
83
|
-
case HttpCallType.post:
|
|
84
|
-
case HttpCallType.put:
|
|
85
|
-
case HttpCallType.patch:
|
|
86
|
+
case http_call_type_enum_1.HttpCallType.post:
|
|
87
|
+
case http_call_type_enum_1.HttpCallType.put:
|
|
88
|
+
case http_call_type_enum_1.HttpCallType.patch:
|
|
86
89
|
if (!(inputParams === null || inputParams === void 0 ? void 0 : inputParams.body)) {
|
|
87
90
|
if (!inputParams) {
|
|
88
91
|
inputParams = {};
|
|
@@ -95,33 +98,33 @@ export class DynamoBEApiService {
|
|
|
95
98
|
});
|
|
96
99
|
break;
|
|
97
100
|
default:
|
|
98
|
-
DBE_Shared.logError('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
|
|
101
|
+
dynamobe_shared_service_1.DBE_Shared.logError('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
|
|
99
102
|
break;
|
|
100
103
|
}
|
|
101
104
|
return a;
|
|
102
105
|
}
|
|
103
106
|
catch (error) {
|
|
104
|
-
DBE_Shared.logError('API ERRROR');
|
|
105
|
-
if (((_b = callParams === null || callParams === void 0 ? void 0 : callParams.httpOptions) === null || _b === void 0 ? void 0 : _b.responseType) === HttpResponseType.text) {
|
|
107
|
+
dynamobe_shared_service_1.DBE_Shared.logError('API ERRROR');
|
|
108
|
+
if (((_b = callParams === null || callParams === void 0 ? void 0 : callParams.httpOptions) === null || _b === void 0 ? void 0 : _b.responseType) === http_response_type_enum_1.HttpResponseType.text) {
|
|
106
109
|
error.error = JSON.parse(error.error);
|
|
107
110
|
}
|
|
108
111
|
if (((_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.flag) === 'DYNAMO-BE ERROR OBJECT') {
|
|
109
|
-
DBE_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
110
|
-
throw new DynamoBEError(error.response.data);
|
|
112
|
+
dynamobe_shared_service_1.DBE_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
113
|
+
throw new dynamobe_error_1.DynamoBEError(error.response.data);
|
|
111
114
|
}
|
|
112
115
|
else if (error.code === 'ENOTFOUND') {
|
|
113
|
-
DBE_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
114
|
-
throw new DynamoBEError({ message: 'DNS error; address cannot be resolved!', status: 404, error: error });
|
|
116
|
+
dynamobe_shared_service_1.DBE_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
117
|
+
throw new dynamobe_error_1.DynamoBEError({ message: 'DNS error; address cannot be resolved!', status: 404, error: error });
|
|
115
118
|
}
|
|
116
119
|
else if (error.config && error.message) {
|
|
117
|
-
throw new DynamoBEError({ status: +error.message.substring(error.message.length - 4, 3), error: error });
|
|
120
|
+
throw new dynamobe_error_1.DynamoBEError({ status: +error.message.substring(error.message.length - 4, 3), error: error });
|
|
118
121
|
}
|
|
119
122
|
else {
|
|
120
|
-
DBE_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
|
|
123
|
+
dynamobe_shared_service_1.DBE_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
|
|
121
124
|
throw error;
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
127
|
});
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
|
-
|
|
130
|
+
exports.DynamoBEApiService = DynamoBEApiService;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoBEApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Mongoose = tslib_1.__importStar(require("mongoose"));
|
|
2
6
|
/* import Mongoose = require("mongoose"); */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
const dynamobe_shared_service_1 = require("./dynamobe-shared.service");
|
|
8
|
+
const dynamobe_singleton_service_1 = require("./dynamobe-singleton.service");
|
|
9
|
+
class DynamoBEApp extends dynamobe_singleton_service_1.DynamoBESingletonService {
|
|
6
10
|
constructor() {
|
|
7
11
|
super();
|
|
8
12
|
this.mongoose = Mongoose;
|
|
@@ -15,16 +19,16 @@ export class DynamoBEApp extends DynamoBESingletonService {
|
|
|
15
19
|
this.setGlobalServiceCollection();
|
|
16
20
|
}
|
|
17
21
|
catch (error) {
|
|
18
|
-
DBE_Shared.logError('\nApplication start failed.\n', error);
|
|
22
|
+
dynamobe_shared_service_1.DBE_Shared.logError('\nApplication start failed.\n', error);
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
startDB() {
|
|
22
26
|
this.mongoose.connection
|
|
23
27
|
.on('error', (error) => {
|
|
24
|
-
DBE_Shared.logError('Unable to connect to MongoDB server, ERROR: ', error);
|
|
28
|
+
dynamobe_shared_service_1.DBE_Shared.logError('Unable to connect to MongoDB server, ERROR: ', error);
|
|
25
29
|
})
|
|
26
30
|
.once('open', () => {
|
|
27
|
-
DBE_Shared.logSuccess('\nConnected to MongoDB\n');
|
|
31
|
+
dynamobe_shared_service_1.DBE_Shared.logSuccess('\nConnected to MongoDB\n');
|
|
28
32
|
});
|
|
29
33
|
this.mongoose.connect(this.params.dbUri, {
|
|
30
34
|
useNewUrlParser: true,
|
|
@@ -32,4 +36,4 @@ export class DynamoBEApp extends DynamoBESingletonService {
|
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
|
-
|
|
39
|
+
exports.DynamoBEApp = DynamoBEApp;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoBEAuthService = void 0;
|
|
4
|
+
const dynamobe_error_1 = require("../_models/fullstack-models/control-models/dynamobe-error");
|
|
5
|
+
const dynamobe_singleton_service_1 = require("./dynamobe-singleton.service");
|
|
6
|
+
class DynamoBEAuthService extends dynamobe_singleton_service_1.DynamoBESingletonService {
|
|
4
7
|
/**
|
|
5
8
|
*
|
|
6
9
|
* @param req
|
|
@@ -9,13 +12,13 @@ export class DynamoBEAuthService extends DynamoBESingletonService {
|
|
|
9
12
|
static getTokenFromRequest(req) {
|
|
10
13
|
const authHeader = req.headers['authorization'];
|
|
11
14
|
if (!authHeader) {
|
|
12
|
-
throw new DynamoBEError({ message: 'AuthHeader missing!' });
|
|
15
|
+
throw new dynamobe_error_1.DynamoBEError({ message: 'AuthHeader missing!' });
|
|
13
16
|
}
|
|
14
17
|
const token = authHeader.split(' ')[1];
|
|
15
18
|
if (!token) {
|
|
16
|
-
throw new DynamoBEError({ message: 'Token missing!' });
|
|
19
|
+
throw new dynamobe_error_1.DynamoBEError({ message: 'Token missing!' });
|
|
17
20
|
}
|
|
18
21
|
return token;
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
|
|
24
|
+
exports.DynamoBEAuthService = DynamoBEAuthService;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoBEController = void 0;
|
|
4
|
+
const dynamobe_singleton_service_1 = require("./dynamobe-singleton.service");
|
|
5
|
+
class DynamoBEController extends dynamobe_singleton_service_1.DynamoBESingletonService {
|
|
3
6
|
constructor() {
|
|
4
7
|
super();
|
|
5
8
|
this.setupEndpoints();
|
|
6
9
|
}
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
exports.DynamoBEController = DynamoBEController;
|