@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,372 +1,372 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DynamoNTS_App = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const Mongoose = require("mongoose");
|
|
6
|
-
const Express = require("express");
|
|
7
|
-
const Https = tslib_1.__importStar(require("https"));
|
|
8
|
-
const FileSystem = tslib_1.__importStar(require("fs"));
|
|
9
|
-
const BodyParser = tslib_1.__importStar(require("body-parser"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
/**
|
|
16
|
-
* This will be the MAIN service of our server project,
|
|
17
|
-
* follow the types and type instructions while setting up your project
|
|
18
|
-
*
|
|
19
|
-
* In this service, there are abstract functions that you will need to implement,
|
|
20
|
-
* where you need to set up the main params for your application.
|
|
21
|
-
*
|
|
22
|
-
* (after the example, you can find the list of services you can/should setup)
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* export class App extends DynamoNTS_AppExtended {
|
|
26
|
-
*
|
|
27
|
-
* ...
|
|
28
|
-
*
|
|
29
|
-
* // Setting up App params, and preparing project global settings
|
|
30
|
-
* setupAppParams(): void {
|
|
31
|
-
* this.params = new DynamoNTS_AppParams({
|
|
32
|
-
* name: 'Warbots Server',
|
|
33
|
-
* title: warbotsTitleLog,
|
|
34
|
-
* version: version,
|
|
35
|
-
* dbName: 'warbots',
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* // dynamoNTS_GlobalSettings.logRequestsContent = false;
|
|
39
|
-
* }
|
|
40
|
-
*
|
|
41
|
-
* ...
|
|
42
|
-
*
|
|
43
|
-
* // Setting up DBServices
|
|
44
|
-
* setGlobalServiceCollection(): void {
|
|
45
|
-
* DynamoNTS_GlobalService.setServices({
|
|
46
|
-
* authService: AuthService.getInstance(),
|
|
47
|
-
* emailServiceCollection: EmailServiceCollectionService.getInstance(),
|
|
48
|
-
* dbModels: [
|
|
49
|
-
* userModelParams,
|
|
50
|
-
* userDataModelParams,
|
|
51
|
-
* userOptionsModelParams,
|
|
52
|
-
* userStatisticsModelParams,
|
|
53
|
-
* userAchievementsModelParams,
|
|
54
|
-
* userNotificationsModelParams,
|
|
55
|
-
*
|
|
56
|
-
* matchStatisticsModelParams,
|
|
57
|
-
* matchDataModelParams,
|
|
58
|
-
|
|
59
|
-
* usageSessionModelParams,
|
|
60
|
-
* customDataModelParams,
|
|
61
|
-
* ]
|
|
62
|
-
* });
|
|
63
|
-
* }
|
|
64
|
-
*
|
|
65
|
-
* ...
|
|
66
|
-
*
|
|
67
|
-
* // Setting up Routes
|
|
68
|
-
* setupRoutingModules(): void {
|
|
69
|
-
* this.httpPort = env.port;
|
|
70
|
-
|
|
71
|
-
* this.routingModules = [
|
|
72
|
-
* new DynamoNTS_RoutingModule({
|
|
73
|
-
* route: '/user',
|
|
74
|
-
* controllers: [
|
|
75
|
-
* UserController.getInstance(),
|
|
76
|
-
* UserDataController.getInstance(),
|
|
77
|
-
* UserOptionsController.getInstance(),
|
|
78
|
-
* UserStatisticsController.getInstance(),
|
|
79
|
-
* UserAchievementsController.getInstance(),
|
|
80
|
-
* UserNotificationsController.getInstance()
|
|
81
|
-
* ]
|
|
82
|
-
* }),
|
|
83
|
-
* new DynamoNTS_RoutingModule({
|
|
84
|
-
* route: '/match',
|
|
85
|
-
* controllers: [
|
|
86
|
-
* MatchController.getInstance(),
|
|
87
|
-
* MatchDistributionController.getInstance(),
|
|
88
|
-
* MatchStatisticsController.getInstance(),
|
|
89
|
-
* ]
|
|
90
|
-
* }),
|
|
91
|
-
* new DynamoNTS_RoutingModule({
|
|
92
|
-
* route: '/server',
|
|
93
|
-
* controllers: [
|
|
94
|
-
* ServerController.getInstance(),
|
|
95
|
-
* ]
|
|
96
|
-
* }),
|
|
97
|
-
|
|
98
|
-
* getTestRoutingModule(),
|
|
99
|
-
* getUsageRoutingModule()
|
|
100
|
-
* ];
|
|
101
|
-
* }
|
|
102
|
-
* }
|
|
103
|
-
*
|
|
104
|
-
* //
|
|
105
|
-
* // The Services available
|
|
106
|
-
* //
|
|
107
|
-
* // Authentication Service
|
|
108
|
-
* // A commonly used basic service,
|
|
109
|
-
* // which is necessary fur certain functions (such as registering call issuers)
|
|
110
|
-
* //
|
|
111
|
-
* // This will handle Authentication Token checking/refreshing, checking issuer's identifier and routeParams,
|
|
112
|
-
* // handling JWT Token, or maybe with OAuth2 or other commonly used security procedures
|
|
113
|
-
* //
|
|
114
|
-
* // You can create one with this Dynamo Object:
|
|
115
|
-
* //
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* // follow the instructions on the abstract class (DynamoNTS_AuthService)
|
|
119
|
-
* export class AuthService extends DynamoNTS_AuthService {}
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* //
|
|
124
|
-
*/
|
|
125
|
-
class DynamoNTS_App extends dynamo_nts_singleton_service_1.DynamoNTS_SingletonService {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.
|
|
151
|
-
this.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
this.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
*
|
|
183
|
-
*/
|
|
184
|
-
startDB() {
|
|
185
|
-
this.mongoose.connection
|
|
186
|
-
.on('error', (error) => {
|
|
187
|
-
fsm_dynamo_1.Dynamo_Log.error('\nUnable to connect to MongoDB server, ERROR: ', error);
|
|
188
|
-
})
|
|
189
|
-
.once('open', () => {
|
|
190
|
-
fsm_dynamo_1.Dynamo_Log.success('\nConnected to MongoDB\n');
|
|
191
|
-
});
|
|
192
|
-
this.mongoose.connect(this._params.dbUri, {
|
|
193
|
-
useNewUrlParser: true,
|
|
194
|
-
useUnifiedTopology: true
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
*
|
|
199
|
-
*/
|
|
200
|
-
initExpresses() {
|
|
201
|
-
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
202
|
-
if (!this._ports.httpPort) {
|
|
203
|
-
let errorMsg = `\nYou have open routes, but httpPort is not set!` +
|
|
204
|
-
`\nsecurity: ${this._security}` +
|
|
205
|
-
`\nset httpPort in DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
206
|
-
errorMsg += '\n\nThe routes setted to use open server:';
|
|
207
|
-
this._routingModules.forEach((module) => {
|
|
208
|
-
if (module.security != dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
209
|
-
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using open sever:`;
|
|
210
|
-
module.endpoints.forEach((endpoint) => {
|
|
211
|
-
if (endpoint.security != dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
212
|
-
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
fsm_dynamo_1.Dynamo_Log.error(errorMsg);
|
|
218
|
-
let error = new Error('Open routes cannot be established!');
|
|
219
|
-
let errorStack = error.stack.split('\n');
|
|
220
|
-
errorStack.splice(1, 2);
|
|
221
|
-
error.stack = errorStack.join('\n');
|
|
222
|
-
throw error;
|
|
223
|
-
}
|
|
224
|
-
this.initOpenExpress();
|
|
225
|
-
}
|
|
226
|
-
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
227
|
-
if (!this._cert || !this._ports.httpsPort) {
|
|
228
|
-
let errorMsg = `\nYou have secure routes, but the certification paths or httpsPort are not set!` +
|
|
229
|
-
`\nsecurity: ${this._security}` +
|
|
230
|
-
`\nset...` +
|
|
231
|
-
`\n httpsPort and` +
|
|
232
|
-
`\n cert: {` +
|
|
233
|
-
`\n keyPath: FileSystem.PathLike,` +
|
|
234
|
-
`\n certPath: FileSystem.PathLike,` +
|
|
235
|
-
`\n }` +
|
|
236
|
-
`\nin DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
237
|
-
errorMsg += '\n\nThe routes setted to use secure server:';
|
|
238
|
-
this._routingModules.forEach((module) => {
|
|
239
|
-
if (module.security != dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
240
|
-
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using secure sever:`;
|
|
241
|
-
module.endpoints.forEach((endpoint) => {
|
|
242
|
-
if (endpoint.security != dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
243
|
-
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
fsm_dynamo_1.Dynamo_Log.error(errorMsg);
|
|
249
|
-
let error = new Error('Secure routes cannot be established!');
|
|
250
|
-
let errorStack = error.stack.split('\n');
|
|
251
|
-
errorStack.splice(1, 2);
|
|
252
|
-
error.stack = errorStack.join('\n');
|
|
253
|
-
throw error;
|
|
254
|
-
}
|
|
255
|
-
this.initSecureExpress();
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
*
|
|
260
|
-
*/
|
|
261
|
-
initOpenExpress() {
|
|
262
|
-
this.openExpress = Express();
|
|
263
|
-
this.openExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
|
|
264
|
-
this.openExpress.use(BodyParser.json({ limit: '50mb' }));
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
*
|
|
268
|
-
*/
|
|
269
|
-
initSecureExpress() {
|
|
270
|
-
this.secureExpress = Express();
|
|
271
|
-
this.secureExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
|
|
272
|
-
this.secureExpress.use(BodyParser.json({ limit: '50mb' }));
|
|
273
|
-
const options = {
|
|
274
|
-
key: FileSystem.readFileSync(this._cert.keyPath),
|
|
275
|
-
cert: FileSystem.readFileSync(this._cert.certPath),
|
|
276
|
-
};
|
|
277
|
-
this.httpsServer = Https.createServer(options, this.secureExpress);
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
*
|
|
281
|
-
*/
|
|
282
|
-
startExpresses() {
|
|
283
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
284
|
-
try {
|
|
285
|
-
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
286
|
-
this.httpsServer
|
|
287
|
-
.listen(this._ports.httpsPort, 'localhost', 0, () => {
|
|
288
|
-
fsm_dynamo_1.Dynamo_Log.success(`\nHTTPS (secure) server is listening on port ${this._ports.httpsPort}\n`);
|
|
289
|
-
})
|
|
290
|
-
.on('error', (error) => {
|
|
291
|
-
fsm_dynamo_1.Dynamo_Log.error(`\nHTTPS (secure) server ERROR`, error);
|
|
292
|
-
})
|
|
293
|
-
.on('uncaughtException', (ex) => {
|
|
294
|
-
fsm_dynamo_1.Dynamo_Log.warn(`\nHTTPS (secure) server uncaughtException`, ex);
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
298
|
-
this.openExpress
|
|
299
|
-
.listen(this._ports.httpPort, () => {
|
|
300
|
-
fsm_dynamo_1.Dynamo_Log.success(`\nHTTP (-open-) server is listening on port ${this._ports.httpPort}\n`);
|
|
301
|
-
})
|
|
302
|
-
.on('error', (error) => {
|
|
303
|
-
fsm_dynamo_1.Dynamo_Log.error(`\nHTTP (-open-) server ERROR`, error);
|
|
304
|
-
})
|
|
305
|
-
.on('uncaughtException', (ex) => {
|
|
306
|
-
fsm_dynamo_1.Dynamo_Log.warn(`\nHTTP (-open-) server uncaughtException`, ex);
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
catch (error) {
|
|
311
|
-
fsm_dynamo_1.Dynamo_Log.error(`startExpresses failed...`, error);
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
*
|
|
317
|
-
*/
|
|
318
|
-
mountSecureRoutes() {
|
|
319
|
-
this._routingModules.forEach((module) => {
|
|
320
|
-
if (module.security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
321
|
-
if (this.debugLog) {
|
|
322
|
-
console.log(`route mount (secure): ${module.route}`);
|
|
323
|
-
}
|
|
324
|
-
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
325
|
-
if (1 < existingRoutes.length) {
|
|
326
|
-
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
327
|
-
let errorStack = error.stack.split('\n');
|
|
328
|
-
errorStack.splice(1, 4);
|
|
329
|
-
error.stack = errorStack.join('\n');
|
|
330
|
-
throw error;
|
|
331
|
-
}
|
|
332
|
-
this.secureExpress.use(module.route, module.secureRouter);
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
*
|
|
338
|
-
*/
|
|
339
|
-
mountOpenRoutes() {
|
|
340
|
-
this._routingModules.forEach((module) => {
|
|
341
|
-
if (module.security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
342
|
-
if (this.debugLog) {
|
|
343
|
-
console.log(`route mount (open): ${module.route}`);
|
|
344
|
-
}
|
|
345
|
-
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
346
|
-
if (1 < existingRoutes.length) {
|
|
347
|
-
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
348
|
-
let errorStack = error.stack.split('\n');
|
|
349
|
-
errorStack.splice(1, 4);
|
|
350
|
-
error.stack = errorStack.join('\n');
|
|
351
|
-
throw error;
|
|
352
|
-
}
|
|
353
|
-
this.openExpress.use(module.route, module.openRouter);
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
*
|
|
359
|
-
*/
|
|
360
|
-
setSecurity() {
|
|
361
|
-
this._routingModules.forEach((module) => {
|
|
362
|
-
if (!this._security) {
|
|
363
|
-
this._security = module.security;
|
|
364
|
-
}
|
|
365
|
-
else if (this._security !== module.security) {
|
|
366
|
-
this._security = dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.both;
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
exports.DynamoNTS_App = DynamoNTS_App;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoNTS_App = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Mongoose = require("mongoose");
|
|
6
|
+
const Express = require("express");
|
|
7
|
+
const Https = tslib_1.__importStar(require("https"));
|
|
8
|
+
const FileSystem = tslib_1.__importStar(require("fs"));
|
|
9
|
+
const BodyParser = tslib_1.__importStar(require("body-parser"));
|
|
10
|
+
const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
|
|
11
|
+
const dynamo_nts_singleton_service_1 = require("./dynamo-nts-singleton.service");
|
|
12
|
+
const dynamo_nts_route_security_enum_1 = require("../_enums/dynamo-nts-route-security.enum");
|
|
13
|
+
const dynamo_nts_global_service_1 = require("./dynamo-nts-global.service");
|
|
14
|
+
const dynamo_nts_global_settings_1 = require("../_constants/dynamo-nts-global-settings");
|
|
15
|
+
/**
|
|
16
|
+
* This will be the MAIN service of our server project,
|
|
17
|
+
* follow the types and type instructions while setting up your project
|
|
18
|
+
*
|
|
19
|
+
* In this service, there are abstract functions that you will need to implement,
|
|
20
|
+
* where you need to set up the main params for your application.
|
|
21
|
+
*
|
|
22
|
+
* (after the example, you can find the list of services you can/should setup)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* export class App extends DynamoNTS_AppExtended {
|
|
26
|
+
*
|
|
27
|
+
* ...
|
|
28
|
+
*
|
|
29
|
+
* // Setting up App params, and preparing project global settings
|
|
30
|
+
* setupAppParams(): void {
|
|
31
|
+
* this.params = new DynamoNTS_AppParams({
|
|
32
|
+
* name: 'Warbots Server',
|
|
33
|
+
* title: warbotsTitleLog,
|
|
34
|
+
* version: version,
|
|
35
|
+
* dbName: 'warbots',
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // dynamoNTS_GlobalSettings.logRequestsContent = false;
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* ...
|
|
42
|
+
*
|
|
43
|
+
* // Setting up DBServices
|
|
44
|
+
* setGlobalServiceCollection(): void {
|
|
45
|
+
* DynamoNTS_GlobalService.setServices({
|
|
46
|
+
* authService: AuthService.getInstance(),
|
|
47
|
+
* emailServiceCollection: EmailServiceCollectionService.getInstance(),
|
|
48
|
+
* dbModels: [
|
|
49
|
+
* userModelParams,
|
|
50
|
+
* userDataModelParams,
|
|
51
|
+
* userOptionsModelParams,
|
|
52
|
+
* userStatisticsModelParams,
|
|
53
|
+
* userAchievementsModelParams,
|
|
54
|
+
* userNotificationsModelParams,
|
|
55
|
+
*
|
|
56
|
+
* matchStatisticsModelParams,
|
|
57
|
+
* matchDataModelParams,
|
|
58
|
+
|
|
59
|
+
* usageSessionModelParams,
|
|
60
|
+
* customDataModelParams,
|
|
61
|
+
* ]
|
|
62
|
+
* });
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* ...
|
|
66
|
+
*
|
|
67
|
+
* // Setting up Routes
|
|
68
|
+
* setupRoutingModules(): void {
|
|
69
|
+
* this.httpPort = env.port;
|
|
70
|
+
|
|
71
|
+
* this.routingModules = [
|
|
72
|
+
* new DynamoNTS_RoutingModule({
|
|
73
|
+
* route: '/user',
|
|
74
|
+
* controllers: [
|
|
75
|
+
* UserController.getInstance(),
|
|
76
|
+
* UserDataController.getInstance(),
|
|
77
|
+
* UserOptionsController.getInstance(),
|
|
78
|
+
* UserStatisticsController.getInstance(),
|
|
79
|
+
* UserAchievementsController.getInstance(),
|
|
80
|
+
* UserNotificationsController.getInstance()
|
|
81
|
+
* ]
|
|
82
|
+
* }),
|
|
83
|
+
* new DynamoNTS_RoutingModule({
|
|
84
|
+
* route: '/match',
|
|
85
|
+
* controllers: [
|
|
86
|
+
* MatchController.getInstance(),
|
|
87
|
+
* MatchDistributionController.getInstance(),
|
|
88
|
+
* MatchStatisticsController.getInstance(),
|
|
89
|
+
* ]
|
|
90
|
+
* }),
|
|
91
|
+
* new DynamoNTS_RoutingModule({
|
|
92
|
+
* route: '/server',
|
|
93
|
+
* controllers: [
|
|
94
|
+
* ServerController.getInstance(),
|
|
95
|
+
* ]
|
|
96
|
+
* }),
|
|
97
|
+
|
|
98
|
+
* getTestRoutingModule(),
|
|
99
|
+
* getUsageRoutingModule()
|
|
100
|
+
* ];
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
*
|
|
104
|
+
* //
|
|
105
|
+
* // The Services available
|
|
106
|
+
* //
|
|
107
|
+
* // Authentication Service
|
|
108
|
+
* // A commonly used basic service,
|
|
109
|
+
* // which is necessary fur certain functions (such as registering call issuers)
|
|
110
|
+
* //
|
|
111
|
+
* // This will handle Authentication Token checking/refreshing, checking issuer's identifier and routeParams,
|
|
112
|
+
* // handling JWT Token, or maybe with OAuth2 or other commonly used security procedures
|
|
113
|
+
* //
|
|
114
|
+
* // You can create one with this Dynamo Object:
|
|
115
|
+
* //
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* // follow the instructions on the abstract class (DynamoNTS_AuthService)
|
|
119
|
+
* export class AuthService extends DynamoNTS_AuthService {}
|
|
120
|
+
*
|
|
121
|
+
*
|
|
122
|
+
*
|
|
123
|
+
* //
|
|
124
|
+
*/
|
|
125
|
+
class DynamoNTS_App extends dynamo_nts_singleton_service_1.DynamoNTS_SingletonService {
|
|
126
|
+
get params() { return this._params; }
|
|
127
|
+
get security() { return this._security; }
|
|
128
|
+
get ports() { return this._ports; }
|
|
129
|
+
get cert() { return this._cert; }
|
|
130
|
+
get routingModules() { return this._routingModules; }
|
|
131
|
+
constructor() {
|
|
132
|
+
var _a;
|
|
133
|
+
super();
|
|
134
|
+
this.mongoose = Mongoose;
|
|
135
|
+
try {
|
|
136
|
+
this._params = this.getAppParams();
|
|
137
|
+
if (this.overrideDynamoNTSGlobalSettings) {
|
|
138
|
+
this.overrideDynamoNTSGlobalSettings();
|
|
139
|
+
}
|
|
140
|
+
dynamo_nts_global_service_1.DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
|
|
141
|
+
dynamo_nts_global_service_1.DynamoNTS_GlobalService.setParams(this.params);
|
|
142
|
+
this._ports = this.getPortSettings();
|
|
143
|
+
if (this.getCertificationSettings) {
|
|
144
|
+
this._cert = this.getCertificationSettings();
|
|
145
|
+
}
|
|
146
|
+
this._routingModules = this.getRoutingModules();
|
|
147
|
+
if (this.createEntries) {
|
|
148
|
+
this.createEntries();
|
|
149
|
+
}
|
|
150
|
+
console.log(`\n\n\nStarting ${this._params.name}... `);
|
|
151
|
+
if (this._params.title) {
|
|
152
|
+
console.log(this._params.title);
|
|
153
|
+
}
|
|
154
|
+
console.log(`\nVersion: ${this._params.version}`);
|
|
155
|
+
this.startDB();
|
|
156
|
+
this.getGlobalServiceCollection();
|
|
157
|
+
this.debugLog = dynamo_nts_global_settings_1.dynamoNTS_GlobalSettings.logSetup;
|
|
158
|
+
this.getRoutingModules();
|
|
159
|
+
this.setSecurity();
|
|
160
|
+
if ((_a = this._routingModules) === null || _a === void 0 ? void 0 : _a.length) {
|
|
161
|
+
this.initExpresses();
|
|
162
|
+
this.startExpresses();
|
|
163
|
+
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
164
|
+
this.mountOpenRoutes();
|
|
165
|
+
}
|
|
166
|
+
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open && this._cert) {
|
|
167
|
+
this.mountSecureRoutes();
|
|
168
|
+
}
|
|
169
|
+
if (this.debugLog) {
|
|
170
|
+
console.log(`\nRoutes mounted.... server using security: ${this._security}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (this.postProcess) {
|
|
174
|
+
this.postProcess();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
fsm_dynamo_1.Dynamo_Log.error('\nApplication start failed.\n', error);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
*
|
|
183
|
+
*/
|
|
184
|
+
startDB() {
|
|
185
|
+
this.mongoose.connection
|
|
186
|
+
.on('error', (error) => {
|
|
187
|
+
fsm_dynamo_1.Dynamo_Log.error('\nUnable to connect to MongoDB server, ERROR: ', error);
|
|
188
|
+
})
|
|
189
|
+
.once('open', () => {
|
|
190
|
+
fsm_dynamo_1.Dynamo_Log.success('\nConnected to MongoDB\n');
|
|
191
|
+
});
|
|
192
|
+
this.mongoose.connect(this._params.dbUri, {
|
|
193
|
+
useNewUrlParser: true,
|
|
194
|
+
useUnifiedTopology: true
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
initExpresses() {
|
|
201
|
+
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
202
|
+
if (!this._ports.httpPort) {
|
|
203
|
+
let errorMsg = `\nYou have open routes, but httpPort is not set!` +
|
|
204
|
+
`\nsecurity: ${this._security}` +
|
|
205
|
+
`\nset httpPort in DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
206
|
+
errorMsg += '\n\nThe routes setted to use open server:';
|
|
207
|
+
this._routingModules.forEach((module) => {
|
|
208
|
+
if (module.security != dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
209
|
+
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using open sever:`;
|
|
210
|
+
module.endpoints.forEach((endpoint) => {
|
|
211
|
+
if (endpoint.security != dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
212
|
+
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
fsm_dynamo_1.Dynamo_Log.error(errorMsg);
|
|
218
|
+
let error = new Error('Open routes cannot be established!');
|
|
219
|
+
let errorStack = error.stack.split('\n');
|
|
220
|
+
errorStack.splice(1, 2);
|
|
221
|
+
error.stack = errorStack.join('\n');
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
this.initOpenExpress();
|
|
225
|
+
}
|
|
226
|
+
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
227
|
+
if (!this._cert || !this._ports.httpsPort) {
|
|
228
|
+
let errorMsg = `\nYou have secure routes, but the certification paths or httpsPort are not set!` +
|
|
229
|
+
`\nsecurity: ${this._security}` +
|
|
230
|
+
`\nset...` +
|
|
231
|
+
`\n httpsPort and` +
|
|
232
|
+
`\n cert: {` +
|
|
233
|
+
`\n keyPath: FileSystem.PathLike,` +
|
|
234
|
+
`\n certPath: FileSystem.PathLike,` +
|
|
235
|
+
`\n }` +
|
|
236
|
+
`\nin DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
237
|
+
errorMsg += '\n\nThe routes setted to use secure server:';
|
|
238
|
+
this._routingModules.forEach((module) => {
|
|
239
|
+
if (module.security != dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
240
|
+
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using secure sever:`;
|
|
241
|
+
module.endpoints.forEach((endpoint) => {
|
|
242
|
+
if (endpoint.security != dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
243
|
+
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
fsm_dynamo_1.Dynamo_Log.error(errorMsg);
|
|
249
|
+
let error = new Error('Secure routes cannot be established!');
|
|
250
|
+
let errorStack = error.stack.split('\n');
|
|
251
|
+
errorStack.splice(1, 2);
|
|
252
|
+
error.stack = errorStack.join('\n');
|
|
253
|
+
throw error;
|
|
254
|
+
}
|
|
255
|
+
this.initSecureExpress();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
*
|
|
260
|
+
*/
|
|
261
|
+
initOpenExpress() {
|
|
262
|
+
this.openExpress = Express();
|
|
263
|
+
this.openExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
|
|
264
|
+
this.openExpress.use(BodyParser.json({ limit: '50mb' }));
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
*
|
|
268
|
+
*/
|
|
269
|
+
initSecureExpress() {
|
|
270
|
+
this.secureExpress = Express();
|
|
271
|
+
this.secureExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
|
|
272
|
+
this.secureExpress.use(BodyParser.json({ limit: '50mb' }));
|
|
273
|
+
const options = {
|
|
274
|
+
key: FileSystem.readFileSync(this._cert.keyPath),
|
|
275
|
+
cert: FileSystem.readFileSync(this._cert.certPath),
|
|
276
|
+
};
|
|
277
|
+
this.httpsServer = Https.createServer(options, this.secureExpress);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
*
|
|
281
|
+
*/
|
|
282
|
+
startExpresses() {
|
|
283
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
284
|
+
try {
|
|
285
|
+
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
286
|
+
this.httpsServer
|
|
287
|
+
.listen(this._ports.httpsPort, 'localhost', 0, () => {
|
|
288
|
+
fsm_dynamo_1.Dynamo_Log.success(`\nHTTPS (secure) server is listening on port ${this._ports.httpsPort}\n`);
|
|
289
|
+
})
|
|
290
|
+
.on('error', (error) => {
|
|
291
|
+
fsm_dynamo_1.Dynamo_Log.error(`\nHTTPS (secure) server ERROR`, error);
|
|
292
|
+
})
|
|
293
|
+
.on('uncaughtException', (ex) => {
|
|
294
|
+
fsm_dynamo_1.Dynamo_Log.warn(`\nHTTPS (secure) server uncaughtException`, ex);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
if (this._security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
298
|
+
this.openExpress
|
|
299
|
+
.listen(this._ports.httpPort, () => {
|
|
300
|
+
fsm_dynamo_1.Dynamo_Log.success(`\nHTTP (-open-) server is listening on port ${this._ports.httpPort}\n`);
|
|
301
|
+
})
|
|
302
|
+
.on('error', (error) => {
|
|
303
|
+
fsm_dynamo_1.Dynamo_Log.error(`\nHTTP (-open-) server ERROR`, error);
|
|
304
|
+
})
|
|
305
|
+
.on('uncaughtException', (ex) => {
|
|
306
|
+
fsm_dynamo_1.Dynamo_Log.warn(`\nHTTP (-open-) server uncaughtException`, ex);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
fsm_dynamo_1.Dynamo_Log.error(`startExpresses failed...`, error);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
*
|
|
317
|
+
*/
|
|
318
|
+
mountSecureRoutes() {
|
|
319
|
+
this._routingModules.forEach((module) => {
|
|
320
|
+
if (module.security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
321
|
+
if (this.debugLog) {
|
|
322
|
+
console.log(`route mount (secure): ${module.route}`);
|
|
323
|
+
}
|
|
324
|
+
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
325
|
+
if (1 < existingRoutes.length) {
|
|
326
|
+
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
327
|
+
let errorStack = error.stack.split('\n');
|
|
328
|
+
errorStack.splice(1, 4);
|
|
329
|
+
error.stack = errorStack.join('\n');
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
this.secureExpress.use(module.route, module.secureRouter);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
*
|
|
338
|
+
*/
|
|
339
|
+
mountOpenRoutes() {
|
|
340
|
+
this._routingModules.forEach((module) => {
|
|
341
|
+
if (module.security !== dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
342
|
+
if (this.debugLog) {
|
|
343
|
+
console.log(`route mount (open): ${module.route}`);
|
|
344
|
+
}
|
|
345
|
+
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
346
|
+
if (1 < existingRoutes.length) {
|
|
347
|
+
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
348
|
+
let errorStack = error.stack.split('\n');
|
|
349
|
+
errorStack.splice(1, 4);
|
|
350
|
+
error.stack = errorStack.join('\n');
|
|
351
|
+
throw error;
|
|
352
|
+
}
|
|
353
|
+
this.openExpress.use(module.route, module.openRouter);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
*
|
|
359
|
+
*/
|
|
360
|
+
setSecurity() {
|
|
361
|
+
this._routingModules.forEach((module) => {
|
|
362
|
+
if (!this._security) {
|
|
363
|
+
this._security = module.security;
|
|
364
|
+
}
|
|
365
|
+
else if (this._security !== module.security) {
|
|
366
|
+
this._security = dynamo_nts_route_security_enum_1.DynamoNTS_RouteSecurity.both;
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
exports.DynamoNTS_App = DynamoNTS_App;
|
|
372
372
|
//# sourceMappingURL=dynamo-nts-app.js.map
|