@futdevpro/nts-dynamo 1.5.77 → 1.5.83
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/LICENSE +2 -2
- package/lib/_constants/dynamo-nts-global-settings.d.ts +2 -2
- package/lib/_constants/dynamo-nts-global-settings.js +17 -17
- package/lib/_constants/index.d.ts +1 -1
- package/lib/_constants/index.js +4 -4
- package/lib/_enums/data-model-type.enum.d.ts +12 -12
- package/lib/_enums/data-model-type.enum.js +16 -16
- package/lib/_enums/data-model-type.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +12 -12
- package/lib/_enums/dynamo-nts-data-service-function.enum.js +18 -18
- package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-route-security.enum.d.ts +11 -11
- package/lib/_enums/dynamo-nts-route-security.enum.js +15 -15
- package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-socket-security.enum.d.ts +10 -10
- package/lib/_enums/dynamo-nts-socket-security.enum.js +14 -14
- package/lib/_enums/dynamo-nts-socket-security.enum.js.map +1 -1
- package/lib/_enums/http/http-call-type.enum.d.ts +11 -11
- package/lib/_enums/http/http-call-type.enum.js +15 -15
- package/lib/_enums/http/http-call-type.enum.js.map +1 -1
- package/lib/_enums/http/http-response-type.enum.d.ts +6 -6
- package/lib/_enums/http/http-response-type.enum.js +10 -10
- package/lib/_enums/http/http-response-type.enum.js.map +1 -1
- package/lib/_enums/http/socket-event.enum.d.ts +9 -8
- package/lib/_enums/http/socket-event.enum.d.ts.map +1 -1
- package/lib/_enums/http/socket-event.enum.js +13 -12
- package/lib/_enums/http/socket-event.enum.js.map +1 -1
- package/lib/_enums/index.d.ts +8 -8
- package/lib/_enums/index.js +13 -13
- package/lib/_enums/predefined-data-types.enum.d.ts +10 -10
- package/lib/_enums/predefined-data-types.enum.js +14 -14
- package/lib/_enums/predefined-data-types.enum.js.map +1 -1
- package/lib/_interfaces/certification-settings.interface.d.ts +7 -0
- package/lib/_interfaces/certification-settings.interface.d.ts.map +1 -0
- package/lib/_interfaces/certification-settings.interface.js +3 -0
- package/lib/_interfaces/certification-settings.interface.js.map +1 -0
- package/lib/_interfaces/global-service-settings.interface.d.ts +18 -0
- package/lib/_interfaces/global-service-settings.interface.d.ts.map +1 -0
- package/lib/_interfaces/global-service-settings.interface.js +3 -0
- package/lib/_interfaces/global-service-settings.interface.js.map +1 -0
- package/lib/_interfaces/index.d.ts +1 -0
- package/lib/_interfaces/index.d.ts.map +1 -0
- package/lib/_interfaces/index.js +4 -0
- package/lib/_interfaces/index.js.map +1 -0
- package/lib/_interfaces/port-settings.interface.d.ts +5 -0
- package/lib/_interfaces/port-settings.interface.d.ts.map +1 -0
- package/lib/_interfaces/port-settings.interface.js +3 -0
- package/lib/_interfaces/port-settings.interface.js.map +1 -0
- package/lib/_models/dynamo-nts-api-call-params.d.ts +95 -95
- package/lib/_models/dynamo-nts-api-call-params.js +47 -47
- package/lib/_models/dynamo-nts-app-params.d.ts +49 -49
- package/lib/_models/dynamo-nts-app-params.js +17 -17
- package/lib/_models/dynamo-nts-endpoint-params.d.ts +80 -80
- package/lib/_models/dynamo-nts-endpoint-params.js +139 -139
- package/lib/_models/dynamo-nts-global-settings.d.ts +53 -53
- package/lib/_models/dynamo-nts-global-settings.js +2 -2
- package/lib/_models/dynamo-nts-routing-module-settings.d.ts +19 -19
- package/lib/_models/dynamo-nts-routing-module-settings.js +2 -2
- package/lib/_models/dynamo-nts-socket-event-params.d.ts +32 -30
- package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.js +80 -79
- package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
- package/lib/_models/dynamo-nts-socket-presence.d.ts +21 -0
- package/lib/_models/dynamo-nts-socket-presence.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-socket-presence.js +45 -0
- package/lib/_models/dynamo-nts-socket-presence.js.map +1 -0
- package/lib/_models/dynamo-nts-socket-service-params.d.ts +18 -18
- package/lib/_models/dynamo-nts-socket-service-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-service-params.js +26 -26
- package/lib/_models/dynamo-nts-socket-service-params.js.map +1 -1
- package/lib/_models/index.d.ts +7 -8
- package/lib/_models/index.d.ts.map +1 -1
- package/lib/_models/index.js +12 -12
- package/lib/_models/index.js.map +1 -1
- package/lib/_modules/api-service.index.d.ts +5 -5
- package/lib/_modules/api-service.index.js +11 -11
- package/lib/_modules/app-extended.index.d.ts +15 -12
- package/lib/_modules/app-extended.index.d.ts.map +1 -1
- package/lib/_modules/app-extended.index.js +23 -19
- package/lib/_modules/app-extended.index.js.map +1 -1
- package/lib/_modules/app.index.d.ts +13 -10
- package/lib/_modules/app.index.d.ts.map +1 -1
- package/lib/_modules/app.index.js +21 -17
- package/lib/_modules/app.index.js.map +1 -1
- package/lib/_modules/auth.index.d.ts +3 -3
- package/lib/_modules/auth.index.js +8 -8
- package/lib/_modules/constants.index.d.ts +1 -1
- package/lib/_modules/constants.index.js +4 -4
- package/lib/_modules/controller.index.d.ts +4 -4
- package/lib/_modules/controller.index.js +10 -10
- package/lib/_modules/custom-data/custom-data.controller.d.ts +5 -5
- package/lib/_modules/custom-data/custom-data.controller.js +55 -55
- package/lib/_modules/custom-data/custom-data.service.d.ts +5 -5
- package/lib/_modules/custom-data/custom-data.service.js +11 -11
- package/lib/_modules/custom-data/get-custom-data-routing-module.d.ts +3 -3
- package/lib/_modules/custom-data/get-custom-data-routing-module.js +17 -17
- package/lib/_modules/custom-data/index.d.ts +4 -4
- package/lib/_modules/custom-data/index.js +8 -8
- package/lib/_modules/custom-data-module.index.d.ts +1 -1
- package/lib/_modules/custom-data-module.index.js +4 -4
- package/lib/_modules/data-service.index.d.ts +5 -5
- package/lib/_modules/data-service.index.js +10 -10
- package/lib/_modules/email.index.d.ts +3 -3
- package/lib/_modules/email.index.js +8 -8
- package/lib/_modules/enums.index.d.ts +1 -1
- package/lib/_modules/enums.index.js +4 -4
- package/lib/_modules/models.index.d.ts +1 -1
- package/lib/_modules/models.index.js +4 -4
- package/lib/_modules/services.index.d.ts +1 -1
- package/lib/_modules/services.index.js +4 -4
- package/lib/_modules/test/get-test-routing-module.d.ts +3 -3
- package/lib/_modules/test/get-test-routing-module.js +17 -17
- package/lib/_modules/test/index.d.ts +3 -3
- package/lib/_modules/test/index.js +7 -7
- package/lib/_modules/test/test.controller.d.ts +5 -5
- package/lib/_modules/test/test.controller.js +104 -104
- package/lib/_modules/test-module.index.d.ts +1 -1
- package/lib/_modules/test-module.index.js +4 -4
- package/lib/_modules/usage/get-usage-routing-module.d.ts +3 -3
- package/lib/_modules/usage/get-usage-routing-module.js +17 -17
- package/lib/_modules/usage/index.d.ts +4 -4
- package/lib/_modules/usage/index.js +8 -8
- package/lib/_modules/usage/usage-controller.d.ts +6 -6
- package/lib/_modules/usage/usage-controller.js +88 -88
- package/lib/_modules/usage/usage.service.d.ts +16 -16
- package/lib/_modules/usage/usage.service.js +132 -132
- package/lib/_modules/usage-module.index.d.ts +1 -1
- package/lib/_modules/usage-module.index.js +4 -4
- package/lib/_services/dynamo-nts-api.service.d.ts +34 -34
- package/lib/_services/dynamo-nts-api.service.js +188 -188
- package/lib/_services/dynamo-nts-app-extended.d.ts +128 -128
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +212 -212
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.d.ts +270 -278
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app.js +371 -371
- package/lib/_services/dynamo-nts-app.js.map +1 -1
- package/lib/_services/dynamo-nts-app.spec.d.ts +1 -0
- package/lib/_services/dynamo-nts-app.spec.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-app.spec.js +10 -0
- package/lib/_services/dynamo-nts-app.spec.js.map +1 -0
- package/lib/_services/dynamo-nts-auth.service.d.ts +127 -127
- package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.js +53 -53
- package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.d.ts +105 -105
- package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.js +57 -57
- package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +230 -230
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-data.service.js +689 -689
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db-service-collection.service.d.ts +8 -8
- package/lib/_services/dynamo-nts-db-service-collection.service.js +10 -10
- package/lib/_services/dynamo-nts-db.service.d.ts +386 -312
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +856 -856
- package/lib/_services/dynamo-nts-db.service.js.map +1 -1
- package/lib/_services/dynamo-nts-email-service-collection.service.d.ts +18 -18
- package/lib/_services/dynamo-nts-email-service-collection.service.js +20 -20
- package/lib/_services/dynamo-nts-email.service.d.ts +56 -56
- package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-email.service.js +203 -203
- package/lib/_services/dynamo-nts-email.service.js.map +1 -1
- package/lib/_services/dynamo-nts-global.service.d.ts +71 -84
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-global.service.js +156 -156
- package/lib/_services/dynamo-nts-global.service.js.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.d.ts +76 -76
- package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.js +191 -191
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.d.ts +31 -31
- package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.js +70 -70
- package/lib/_services/dynamo-nts-shared.service.js.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.spec.d.ts +2 -0
- package/lib/_services/dynamo-nts-shared.service.spec.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-shared.service.spec.js +12 -0
- package/lib/_services/dynamo-nts-shared.service.spec.js.map +1 -0
- package/lib/_services/dynamo-nts-singleton.service.d.ts +8 -8
- package/lib/_services/dynamo-nts-singleton.service.js +18 -18
- package/lib/_services/dynamo-nts-singleton.service.js.map +1 -1
- package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts +9 -9
- package/lib/_services/dynamo-nts-socket-service-collection.service.js +13 -13
- package/lib/_services/dynamo-nts-socket.service.d.ts +57 -45
- package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.js +188 -165
- package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
- package/lib/_services/index.d.ts +14 -16
- package/lib/_services/index.d.ts.map +1 -1
- package/lib/_services/index.js +20 -20
- package/lib/_services/index.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +14 -14
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package SAVE.json +216 -0
- package/package-NEW with test but not working.json +228 -0
- package/package.json +14 -8
- package/spec/support/jasmine.json +14 -0
- package/src/_enums/http/socket-event.enum.ts +2 -1
- package/src/_interfaces/certification-settings.interface.ts +7 -0
- package/src/_interfaces/global-service-settings.interface.ts +23 -0
- package/src/_interfaces/index.ts +5 -0
- package/src/_interfaces/port-settings.interface.ts +5 -0
- package/src/_models/dynamo-nts-socket-event-params.ts +23 -21
- package/src/_models/{dynamo-nts-socket-dictionary.ts → dynamo-nts-socket-presence.ts} +21 -5
- package/src/_models/dynamo-nts-socket-service-params.ts +1 -0
- package/src/_models/index.ts +2 -2
- package/src/_modules/app-extended.index.ts +7 -2
- package/src/_modules/app.index.ts +5 -0
- package/src/_services/dynamo-nts-app-extended.ts +6 -2
- package/src/_services/dynamo-nts-app.spec.ts +14 -0
- package/src/_services/dynamo-nts-app.ts +8 -14
- package/src/_services/dynamo-nts-auth.service.ts +1 -0
- package/src/_services/dynamo-nts-controller.service.ts +2 -1
- package/src/_services/dynamo-nts-data.service.ts +19 -19
- package/src/_services/dynamo-nts-db.service.ts +195 -115
- package/src/_services/dynamo-nts-email.service.ts +1 -0
- package/src/_services/dynamo-nts-global.service.ts +3 -18
- package/src/_services/dynamo-nts-routing-module.service.ts +1 -0
- package/src/_services/dynamo-nts-shared.service.spec.ts +10 -0
- package/src/_services/dynamo-nts-shared.service.ts +2 -1
- package/src/_services/dynamo-nts-socket.service.ts +80 -41
- package/src/_services/index.ts +2 -2
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DynamoNTS_RoutingModule = void 0;
|
|
4
|
-
const express_1 = require("express");
|
|
5
|
-
const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
|
|
6
|
-
const dynamo_nts_global_settings_1 = require("../_constants/dynamo-nts-global-settings");
|
|
7
|
-
const dynamo_nts_route_security_enum_1 = require("../_enums/dynamo-nts-route-security.enum");
|
|
8
|
-
const http_call_type_enum_1 = require("../_enums/http/http-call-type.enum");
|
|
9
|
-
/**
|
|
10
|
-
* Routing Module
|
|
11
|
-
* Handling route setup and control
|
|
12
|
-
*
|
|
13
|
-
* You can add routes and controllers for them
|
|
14
|
-
* @example
|
|
15
|
-
* // Setting up Routes
|
|
16
|
-
* setupRoutingModules(): void {
|
|
17
|
-
* this.httpPort = env.port;
|
|
18
|
-
|
|
19
|
-
* this.routingModules = [
|
|
20
|
-
* new DynamoNTS_RoutingModule({
|
|
21
|
-
* route: '/user',
|
|
22
|
-
* controllers: [
|
|
23
|
-
* UserController.getInstance(),
|
|
24
|
-
* UserDataController.getInstance(),
|
|
25
|
-
* UserOptionsController.getInstance(),
|
|
26
|
-
* UserStatisticsController.getInstance(),
|
|
27
|
-
* UserAchievementsController.getInstance(),
|
|
28
|
-
* UserNotificationsController.getInstance()
|
|
29
|
-
* ]
|
|
30
|
-
* }),
|
|
31
|
-
* new DynamoNTS_RoutingModule({
|
|
32
|
-
* route: '/match',
|
|
33
|
-
* controllers: [
|
|
34
|
-
* MatchController.getInstance(),
|
|
35
|
-
* MatchDistributionController.getInstance(),
|
|
36
|
-
* MatchStatisticsController.getInstance(),
|
|
37
|
-
* ]
|
|
38
|
-
* }),
|
|
39
|
-
* new DynamoNTS_RoutingModule({
|
|
40
|
-
* route: '/server',
|
|
41
|
-
* controllers: [
|
|
42
|
-
* ServerController.getInstance(),
|
|
43
|
-
* ]
|
|
44
|
-
* }),
|
|
45
|
-
|
|
46
|
-
* getTestRoutingModule(),
|
|
47
|
-
* getUsageRoutingModule()
|
|
48
|
-
* ];
|
|
49
|
-
* }
|
|
50
|
-
*/
|
|
51
|
-
class DynamoNTS_RoutingModule {
|
|
52
|
-
constructor(set) {
|
|
53
|
-
this.endpoints = [];
|
|
54
|
-
this.openRouter = (0, express_1.Router)();
|
|
55
|
-
this.secureRouter = (0, express_1.Router)();
|
|
56
|
-
this.log = dynamo_nts_global_settings_1.dynamoNTS_GlobalSettings.logSetup;
|
|
57
|
-
this.defaultErrorUserMsg = `We encountered an uncought BackEnd Build Error, ` +
|
|
58
|
-
`\nplease contact the responsible development team.`;
|
|
59
|
-
try {
|
|
60
|
-
this.route = dynamo_nts_global_settings_1.dynamoNTS_GlobalSettings.baseUrl + set.route;
|
|
61
|
-
this.controllers = set.controllers;
|
|
62
|
-
this.setupRoutes();
|
|
63
|
-
this.mountRoutes(set.securityOverride);
|
|
64
|
-
if (this.log)
|
|
65
|
-
console.log(`routing module setup done: ${this.route} serurity: ${this.security}\n`);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
fsm_dynamo_1.Dynamo_Log.error(`Routing module setup failed (${this.route})`, error);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* You must setup endpoints and required services for this function
|
|
73
|
-
*/
|
|
74
|
-
setupRoutes() {
|
|
75
|
-
this.controllers.forEach((controller) => {
|
|
76
|
-
this.endpoints.push(...controller.endpoints);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
* @param securityOverride
|
|
82
|
-
*/
|
|
83
|
-
mountRoutes(securityOverride) {
|
|
84
|
-
if (securityOverride) {
|
|
85
|
-
this.security = securityOverride;
|
|
86
|
-
}
|
|
87
|
-
this.endpoints.forEach((endpoint) => {
|
|
88
|
-
if (securityOverride) {
|
|
89
|
-
endpoint.security = securityOverride;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
if (!this.security) {
|
|
93
|
-
this.security = endpoint.security;
|
|
94
|
-
}
|
|
95
|
-
else if (this.security !== endpoint.security) {
|
|
96
|
-
this.security = dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.both;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (this.log)
|
|
100
|
-
console.log(`endpoint mount (${endpoint.security}): ${this.route}${endpoint.endpoint}`);
|
|
101
|
-
const existingEndPoints = this.endpoints.filter((ep) => ep.endpoint === endpoint.endpoint);
|
|
102
|
-
if (1 < existingEndPoints.length) {
|
|
103
|
-
let error = new Error(`ENDPOINT DUPLICATION: ${endpoint.endpoint}`);
|
|
104
|
-
let errorStack = error.stack.split('\n');
|
|
105
|
-
errorStack.splice(1, 4);
|
|
106
|
-
error.stack = errorStack.join('\n');
|
|
107
|
-
throw error;
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
if (endpoint.security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
111
|
-
this.mountOpenRoute(endpoint);
|
|
112
|
-
}
|
|
113
|
-
if (endpoint.security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
114
|
-
this.mountSecureRoute(endpoint);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
throw new fsm_dynamo_1.Dynamo_Error({
|
|
119
|
-
errorCode: 'NTS-RM9-100',
|
|
120
|
-
addECToUserMsg: true,
|
|
121
|
-
message: `DYNAMO-NTS ERROR: Failed to mount routes.`,
|
|
122
|
-
userMessage: this.defaultErrorUserMsg,
|
|
123
|
-
error
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
* @param endpointParams
|
|
131
|
-
*/
|
|
132
|
-
mountOpenRoute(endpointParams) {
|
|
133
|
-
switch (endpointParams.type) {
|
|
134
|
-
case http_call_type_enum_1.HttpCallType.get:
|
|
135
|
-
this.openRouter.get(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
136
|
-
break;
|
|
137
|
-
case http_call_type_enum_1.HttpCallType.post:
|
|
138
|
-
this.openRouter.post(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
139
|
-
break;
|
|
140
|
-
case http_call_type_enum_1.HttpCallType.put:
|
|
141
|
-
this.openRouter.put(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
142
|
-
break;
|
|
143
|
-
case http_call_type_enum_1.HttpCallType.patch:
|
|
144
|
-
this.openRouter.patch(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
145
|
-
break;
|
|
146
|
-
case http_call_type_enum_1.HttpCallType.delete:
|
|
147
|
-
this.openRouter.delete(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
148
|
-
break;
|
|
149
|
-
default:
|
|
150
|
-
throw new fsm_dynamo_1.Dynamo_Error({
|
|
151
|
-
errorCode: 'NTS-RM9-200',
|
|
152
|
-
addECToUserMsg: true,
|
|
153
|
-
message: `DYNAMO-NTS ERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}`,
|
|
154
|
-
userMessage: this.defaultErrorUserMsg,
|
|
155
|
-
error: new Error()
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
*
|
|
161
|
-
* @param endpointParams
|
|
162
|
-
*/
|
|
163
|
-
mountSecureRoute(endpointParams) {
|
|
164
|
-
switch (endpointParams.type) {
|
|
165
|
-
case http_call_type_enum_1.HttpCallType.get:
|
|
166
|
-
this.secureRouter.get(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
167
|
-
break;
|
|
168
|
-
case http_call_type_enum_1.HttpCallType.post:
|
|
169
|
-
this.secureRouter.post(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
170
|
-
break;
|
|
171
|
-
case http_call_type_enum_1.HttpCallType.put:
|
|
172
|
-
this.secureRouter.put(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
173
|
-
break;
|
|
174
|
-
case http_call_type_enum_1.HttpCallType.patch:
|
|
175
|
-
this.secureRouter.patch(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
176
|
-
break;
|
|
177
|
-
case http_call_type_enum_1.HttpCallType.delete:
|
|
178
|
-
this.secureRouter.delete(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
179
|
-
break;
|
|
180
|
-
default:
|
|
181
|
-
throw new fsm_dynamo_1.Dynamo_Error({
|
|
182
|
-
errorCode: 'NTS-RM9-300',
|
|
183
|
-
addECToUserMsg: true,
|
|
184
|
-
message: `DYNAMO-NTS ERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}`,
|
|
185
|
-
userMessage: this.defaultErrorUserMsg,
|
|
186
|
-
error: new Error()
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
exports.DynamoNTS_RoutingModule = DynamoNTS_RoutingModule;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoNTS_RoutingModule = void 0;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
|
|
6
|
+
const dynamo_nts_global_settings_1 = require("../_constants/dynamo-nts-global-settings");
|
|
7
|
+
const dynamo_nts_route_security_enum_1 = require("../_enums/dynamo-nts-route-security.enum");
|
|
8
|
+
const http_call_type_enum_1 = require("../_enums/http/http-call-type.enum");
|
|
9
|
+
/**
|
|
10
|
+
* Routing Module
|
|
11
|
+
* Handling route setup and control
|
|
12
|
+
*
|
|
13
|
+
* You can add routes and controllers for them
|
|
14
|
+
* @example
|
|
15
|
+
* // Setting up Routes
|
|
16
|
+
* setupRoutingModules(): void {
|
|
17
|
+
* this.httpPort = env.port;
|
|
18
|
+
|
|
19
|
+
* this.routingModules = [
|
|
20
|
+
* new DynamoNTS_RoutingModule({
|
|
21
|
+
* route: '/user',
|
|
22
|
+
* controllers: [
|
|
23
|
+
* UserController.getInstance(),
|
|
24
|
+
* UserDataController.getInstance(),
|
|
25
|
+
* UserOptionsController.getInstance(),
|
|
26
|
+
* UserStatisticsController.getInstance(),
|
|
27
|
+
* UserAchievementsController.getInstance(),
|
|
28
|
+
* UserNotificationsController.getInstance()
|
|
29
|
+
* ]
|
|
30
|
+
* }),
|
|
31
|
+
* new DynamoNTS_RoutingModule({
|
|
32
|
+
* route: '/match',
|
|
33
|
+
* controllers: [
|
|
34
|
+
* MatchController.getInstance(),
|
|
35
|
+
* MatchDistributionController.getInstance(),
|
|
36
|
+
* MatchStatisticsController.getInstance(),
|
|
37
|
+
* ]
|
|
38
|
+
* }),
|
|
39
|
+
* new DynamoNTS_RoutingModule({
|
|
40
|
+
* route: '/server',
|
|
41
|
+
* controllers: [
|
|
42
|
+
* ServerController.getInstance(),
|
|
43
|
+
* ]
|
|
44
|
+
* }),
|
|
45
|
+
|
|
46
|
+
* getTestRoutingModule(),
|
|
47
|
+
* getUsageRoutingModule()
|
|
48
|
+
* ];
|
|
49
|
+
* }
|
|
50
|
+
*/
|
|
51
|
+
class DynamoNTS_RoutingModule {
|
|
52
|
+
constructor(set) {
|
|
53
|
+
this.endpoints = [];
|
|
54
|
+
this.openRouter = (0, express_1.Router)();
|
|
55
|
+
this.secureRouter = (0, express_1.Router)();
|
|
56
|
+
this.log = dynamo_nts_global_settings_1.dynamoNTS_GlobalSettings.logSetup;
|
|
57
|
+
this.defaultErrorUserMsg = `We encountered an uncought BackEnd Build Error, ` +
|
|
58
|
+
`\nplease contact the responsible development team.`;
|
|
59
|
+
try {
|
|
60
|
+
this.route = dynamo_nts_global_settings_1.dynamoNTS_GlobalSettings.baseUrl + set.route;
|
|
61
|
+
this.controllers = set.controllers;
|
|
62
|
+
this.setupRoutes();
|
|
63
|
+
this.mountRoutes(set.securityOverride);
|
|
64
|
+
if (this.log)
|
|
65
|
+
console.log(`routing module setup done: ${this.route} serurity: ${this.security}\n`);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
fsm_dynamo_1.Dynamo_Log.error(`Routing module setup failed (${this.route})`, error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* You must setup endpoints and required services for this function
|
|
73
|
+
*/
|
|
74
|
+
setupRoutes() {
|
|
75
|
+
this.controllers.forEach((controller) => {
|
|
76
|
+
this.endpoints.push(...controller.endpoints);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param securityOverride
|
|
82
|
+
*/
|
|
83
|
+
mountRoutes(securityOverride) {
|
|
84
|
+
if (securityOverride) {
|
|
85
|
+
this.security = securityOverride;
|
|
86
|
+
}
|
|
87
|
+
this.endpoints.forEach((endpoint) => {
|
|
88
|
+
if (securityOverride) {
|
|
89
|
+
endpoint.security = securityOverride;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
if (!this.security) {
|
|
93
|
+
this.security = endpoint.security;
|
|
94
|
+
}
|
|
95
|
+
else if (this.security !== endpoint.security) {
|
|
96
|
+
this.security = dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.both;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (this.log)
|
|
100
|
+
console.log(`endpoint mount (${endpoint.security}): ${this.route}${endpoint.endpoint}`);
|
|
101
|
+
const existingEndPoints = this.endpoints.filter((ep) => ep.endpoint === endpoint.endpoint);
|
|
102
|
+
if (1 < existingEndPoints.length) {
|
|
103
|
+
let error = new Error(`ENDPOINT DUPLICATION: ${endpoint.endpoint}`);
|
|
104
|
+
let errorStack = error.stack.split('\n');
|
|
105
|
+
errorStack.splice(1, 4);
|
|
106
|
+
error.stack = errorStack.join('\n');
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
if (endpoint.security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
111
|
+
this.mountOpenRoute(endpoint);
|
|
112
|
+
}
|
|
113
|
+
if (endpoint.security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
114
|
+
this.mountSecureRoute(endpoint);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
119
|
+
errorCode: 'NTS-RM9-100',
|
|
120
|
+
addECToUserMsg: true,
|
|
121
|
+
message: `DYNAMO-NTS ERROR: Failed to mount routes.`,
|
|
122
|
+
userMessage: this.defaultErrorUserMsg,
|
|
123
|
+
error
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
*
|
|
130
|
+
* @param endpointParams
|
|
131
|
+
*/
|
|
132
|
+
mountOpenRoute(endpointParams) {
|
|
133
|
+
switch (endpointParams.type) {
|
|
134
|
+
case http_call_type_enum_1.HttpCallType.get:
|
|
135
|
+
this.openRouter.get(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
136
|
+
break;
|
|
137
|
+
case http_call_type_enum_1.HttpCallType.post:
|
|
138
|
+
this.openRouter.post(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
139
|
+
break;
|
|
140
|
+
case http_call_type_enum_1.HttpCallType.put:
|
|
141
|
+
this.openRouter.put(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
142
|
+
break;
|
|
143
|
+
case http_call_type_enum_1.HttpCallType.patch:
|
|
144
|
+
this.openRouter.patch(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
145
|
+
break;
|
|
146
|
+
case http_call_type_enum_1.HttpCallType.delete:
|
|
147
|
+
this.openRouter.delete(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
151
|
+
errorCode: 'NTS-RM9-200',
|
|
152
|
+
addECToUserMsg: true,
|
|
153
|
+
message: `DYNAMO-NTS ERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}`,
|
|
154
|
+
userMessage: this.defaultErrorUserMsg,
|
|
155
|
+
error: new Error()
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
*
|
|
161
|
+
* @param endpointParams
|
|
162
|
+
*/
|
|
163
|
+
mountSecureRoute(endpointParams) {
|
|
164
|
+
switch (endpointParams.type) {
|
|
165
|
+
case http_call_type_enum_1.HttpCallType.get:
|
|
166
|
+
this.secureRouter.get(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
167
|
+
break;
|
|
168
|
+
case http_call_type_enum_1.HttpCallType.post:
|
|
169
|
+
this.secureRouter.post(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
170
|
+
break;
|
|
171
|
+
case http_call_type_enum_1.HttpCallType.put:
|
|
172
|
+
this.secureRouter.put(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
173
|
+
break;
|
|
174
|
+
case http_call_type_enum_1.HttpCallType.patch:
|
|
175
|
+
this.secureRouter.patch(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
176
|
+
break;
|
|
177
|
+
case http_call_type_enum_1.HttpCallType.delete:
|
|
178
|
+
this.secureRouter.delete(endpointParams.endpoint, endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
179
|
+
break;
|
|
180
|
+
default:
|
|
181
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
182
|
+
errorCode: 'NTS-RM9-300',
|
|
183
|
+
addECToUserMsg: true,
|
|
184
|
+
message: `DYNAMO-NTS ERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}`,
|
|
185
|
+
userMessage: this.defaultErrorUserMsg,
|
|
186
|
+
error: new Error()
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.DynamoNTS_RoutingModule = DynamoNTS_RoutingModule;
|
|
192
192
|
//# sourceMappingURL=dynamo-nts-routing-module.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamo-nts-routing-module.service.js","sourceRoot":"","sources":["../../src/_services/dynamo-nts-routing-module.service.ts"],"names":[],"mappings":";;;AACA,qCAAiC;
|
|
1
|
+
{"version":3,"file":"dynamo-nts-routing-module.service.js","sourceRoot":"","sources":["../../src/_services/dynamo-nts-routing-module.service.ts"],"names":[],"mappings":";;;AACA,qCAAiC;AAEjC,sDAAiE;AAEjE,yFAAoF;AACpF,6FAAmF;AACnF,4EAAkE;AAKlE;;;;;;;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E,MAAM;YACR;gBACE,MAAM,IAAI,yBAAY,CAAC;oBACrB,SAAS,EAAE,aAAa;oBACxB,cAAc,EAAE,IAAI;oBACpB,OAAO,EAAE,yCAAyC,cAAc,CAAC,IAAI,MAAM,cAAc,CAAC,IAAI,EAAE;oBAChG,WAAW,EAAE,IAAI,CAAC,mBAAmB;oBACrC,KAAK,EAAE,IAAI,KAAK,EAAE;iBACnB,CAAC,CAAA;SACL;IACH,CAAC;CACF;AApKD,0DAoKC"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { Request } from 'express';
|
|
2
|
-
import { GeoIpLocation, Dynamo_Shared } from '@futdevpro/fsm-dynamo/shared-service';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
export declare class DynamoNTS_Shared extends Dynamo_Shared {
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param request
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
static getIpFromRequest(request: Request): string;
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param request
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
static getLocationDataByRequest(request: Request): GeoIpLocation;
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param request
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
static getLocationByIp(ip: string): GeoIpLocation;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param question
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
static prompt(question: string): Promise<string>;
|
|
31
|
-
}
|
|
1
|
+
import { Request } from 'express';
|
|
2
|
+
import { GeoIpLocation, Dynamo_Shared } from '@futdevpro/fsm-dynamo/shared-service';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare class DynamoNTS_Shared extends Dynamo_Shared {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param request
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
static getIpFromRequest(request: Request): string;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param request
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
static getLocationDataByRequest(request: Request): GeoIpLocation;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param request
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
static getLocationByIp(ip: string): GeoIpLocation;
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param question
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
static prompt(question: string): Promise<string>;
|
|
31
|
+
}
|
|
32
32
|
//# sourceMappingURL=dynamo-nts-shared.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamo-nts-shared.service.d.ts","sourceRoot":"","sources":["../../src/_services/dynamo-nts-shared.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamo-nts-shared.service.d.ts","sourceRoot":"","sources":["../../src/_services/dynamo-nts-shared.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAEpF;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IAEjD;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAYjD;;;;OAIG;IACH,MAAM,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa;IAIhE;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa;IAIjD;;;;OAIG;WACU,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBvD"}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DynamoNTS_Shared = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const ReadLine = tslib_1.__importStar(require("readline"));
|
|
6
|
-
const GeoIp = tslib_1.__importStar(require("geoip-lite"));
|
|
7
|
-
const shared_service_1 = require("@futdevpro/fsm-dynamo/shared-service");
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
class DynamoNTS_Shared extends shared_service_1.Dynamo_Shared {
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param request
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
static getIpFromRequest(request) {
|
|
18
|
-
let ip;
|
|
19
|
-
if (request.headers['x-forwarded-for']) {
|
|
20
|
-
const route = request.headers['x-forwarded-for'].split(', ');
|
|
21
|
-
console.log('TESTTTT route:', route);
|
|
22
|
-
ip = route[route.length - 1];
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
ip = request.socket.remoteAddress;
|
|
26
|
-
}
|
|
27
|
-
return ip;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @param request
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
static getLocationDataByRequest(request) {
|
|
35
|
-
return GeoIp.lookup(this.getIpFromRequest(request));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param request
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
static getLocationByIp(ip) {
|
|
43
|
-
return GeoIp.lookup(ip);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param question
|
|
48
|
-
* @returns
|
|
49
|
-
*/
|
|
50
|
-
static prompt(question) {
|
|
51
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const readLine = ReadLine.createInterface({
|
|
53
|
-
input: process.stdin,
|
|
54
|
-
output: process.stdout
|
|
55
|
-
});
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
try {
|
|
58
|
-
readLine.question(question, (result) => {
|
|
59
|
-
resolve(result);
|
|
60
|
-
readLine.close();
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
reject(error);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.DynamoNTS_Shared = DynamoNTS_Shared;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoNTS_Shared = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ReadLine = tslib_1.__importStar(require("readline"));
|
|
6
|
+
const GeoIp = tslib_1.__importStar(require("geoip-lite"));
|
|
7
|
+
const shared_service_1 = require("@futdevpro/fsm-dynamo/shared-service");
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
class DynamoNTS_Shared extends shared_service_1.Dynamo_Shared {
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param request
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
static getIpFromRequest(request) {
|
|
18
|
+
let ip;
|
|
19
|
+
if (request.headers['x-forwarded-for']) {
|
|
20
|
+
const route = request.headers['x-forwarded-for'].split(', ');
|
|
21
|
+
console.log('TESTTTT route:', route);
|
|
22
|
+
ip = route[route.length - 1];
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
ip = request.socket.remoteAddress;
|
|
26
|
+
}
|
|
27
|
+
return ip;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param request
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
static getLocationDataByRequest(request) {
|
|
35
|
+
return GeoIp.lookup(this.getIpFromRequest(request));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param request
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
static getLocationByIp(ip) {
|
|
43
|
+
return GeoIp.lookup(ip);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param question
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
static prompt(question) {
|
|
51
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const readLine = ReadLine.createInterface({
|
|
53
|
+
input: process.stdin,
|
|
54
|
+
output: process.stdout
|
|
55
|
+
});
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
try {
|
|
58
|
+
readLine.question(question, (result) => {
|
|
59
|
+
resolve(result);
|
|
60
|
+
readLine.close();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
reject(error);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.DynamoNTS_Shared = DynamoNTS_Shared;
|
|
71
71
|
//# sourceMappingURL=dynamo-nts-shared.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamo-nts-shared.service.js","sourceRoot":"","sources":["../../src/_services/dynamo-nts-shared.service.ts"],"names":[],"mappings":";;;;AACA,2DAAqC;
|
|
1
|
+
{"version":3,"file":"dynamo-nts-shared.service.js","sourceRoot":"","sources":["../../src/_services/dynamo-nts-shared.service.ts"],"names":[],"mappings":";;;;AACA,2DAAqC;AACrC,0DAAoC;AAGpC,yEAAoF;AAEpF;;GAEG;AACH,MAAa,gBAAiB,SAAQ,8BAAa;IAEjD;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAgB;QACtC,IAAI,EAAU,CAAC;QACf,IAAI,OAAO,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamo-nts-shared.service.spec.d.ts","sourceRoot":"","sources":["../../src/_services/dynamo-nts-shared.service.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const dynamo_nts_shared_service_1 = require("./dynamo-nts-shared.service");
|
|
4
|
+
describe('DynamoNTS_Shared', () => {
|
|
5
|
+
it('fns should be accessible', () => {
|
|
6
|
+
expect(dynamo_nts_shared_service_1.DynamoNTS_Shared.getIpFromRequest).toBeTruthy();
|
|
7
|
+
expect(dynamo_nts_shared_service_1.DynamoNTS_Shared.getLocationDataByRequest).toBeTruthy();
|
|
8
|
+
expect(dynamo_nts_shared_service_1.DynamoNTS_Shared.getLocationByIp).toBeTruthy();
|
|
9
|
+
expect(dynamo_nts_shared_service_1.DynamoNTS_Shared.prompt).toBeTruthy();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=dynamo-nts-shared.service.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamo-nts-shared.service.spec.js","sourceRoot":"","sources":["../../src/_services/dynamo-nts-shared.service.spec.ts"],"names":[],"mappings":";;AAAA,2EAA+D;AAE/D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QAClC,MAAM,CAAC,4CAAgB,CAAC,gBAAgB,CAAC,CAAC,UAAU,EAAE,CAAC;QACvD,MAAM,CAAC,4CAAgB,CAAC,wBAAwB,CAAC,CAAC,UAAU,EAAE,CAAC;QAC/D,MAAM,CAAC,4CAAgB,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,CAAC;QACtD,MAAM,CAAC,4CAAgB,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|