@futdevpro/nts-dynamo 1.5.69 → 1.5.72
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/_models/dynamo-nts-api-call-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-api-call-params.js +3 -1
- package/lib/_models/dynamo-nts-api-call-params.js.map +1 -1
- package/lib/_models/dynamo-nts-app-params.js +3 -2
- package/lib/_models/dynamo-nts-app-params.js.map +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.js +12 -8
- package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
- package/lib/_modules/constants.index.d.ts +2 -0
- package/lib/_modules/constants.index.d.ts.map +1 -0
- package/lib/_modules/constants.index.js +5 -0
- package/lib/_modules/constants.index.js.map +1 -0
- package/lib/_modules/custom-data-module.index.d.ts +2 -0
- package/lib/_modules/custom-data-module.index.d.ts.map +1 -0
- package/lib/_modules/custom-data-module.index.js +5 -0
- package/lib/_modules/custom-data-module.index.js.map +1 -0
- package/lib/_modules/enums.index.d.ts +2 -0
- package/lib/_modules/enums.index.d.ts.map +1 -0
- package/lib/_modules/enums.index.js +5 -0
- package/lib/_modules/enums.index.js.map +1 -0
- package/lib/_modules/models.index.d.ts +2 -0
- package/lib/_modules/models.index.d.ts.map +1 -0
- package/lib/_modules/models.index.js +5 -0
- package/lib/_modules/models.index.js.map +1 -0
- package/lib/_modules/services.index.d.ts +2 -0
- package/lib/_modules/services.index.d.ts.map +1 -0
- package/lib/_modules/services.index.js +5 -0
- package/lib/_modules/services.index.js.map +1 -0
- package/lib/_modules/test/test.controller.d.ts.map +1 -1
- package/lib/_modules/test/test.controller.js +4 -1
- package/lib/_modules/test/test.controller.js.map +1 -1
- package/lib/_modules/test-module.index.d.ts +2 -0
- package/lib/_modules/test-module.index.d.ts.map +1 -0
- package/lib/_modules/test-module.index.js +5 -0
- package/lib/_modules/test-module.index.js.map +1 -0
- package/lib/_modules/usage-module.index.d.ts +2 -0
- package/lib/_modules/usage-module.index.d.ts.map +1 -0
- package/lib/_modules/usage-module.index.js +5 -0
- package/lib/_modules/usage-module.index.js.map +1 -0
- package/lib/_services/dynamo-nts-app-extended.d.ts +5 -1
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +6 -4
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.d.ts +46 -37
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app.js +67 -39
- package/lib/_services/dynamo-nts-app.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +2 -0
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-data.service.js +38 -38
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db.service.d.ts +10 -11
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +76 -224
- package/lib/_services/dynamo-nts-db.service.js.map +1 -1
- package/lib/_services/dynamo-nts-global.service.d.ts +22 -14
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-global.service.js +7 -0
- package/lib/_services/dynamo-nts-global.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/_models/dynamo-nts-api-call-params.ts +5 -1
- package/src/_models/dynamo-nts-app-params.ts +2 -2
- package/src/_models/dynamo-nts-endpoint-params.ts +22 -8
- package/src/_modules/constants.index.ts +2 -0
- package/src/_modules/custom-data-module.index.ts +2 -0
- package/src/_modules/enums.index.ts +2 -0
- package/src/_modules/models.index.ts +2 -0
- package/src/_modules/services.index.ts +2 -0
- package/src/_modules/test/test.controller.ts +4 -1
- package/src/_modules/test-module.index.ts +2 -0
- package/src/_modules/usage-module.index.ts +2 -0
- package/src/_services/dynamo-nts-app-extended.ts +11 -4
- package/src/_services/dynamo-nts-app.ts +131 -76
- package/src/_services/dynamo-nts-data.service.ts +44 -38
- package/src/_services/dynamo-nts-db.service.ts +92 -229
- package/src/_services/dynamo-nts-global.service.ts +30 -18
|
@@ -4,6 +4,7 @@ import { testModuleSettings } from '@futdevpro/fsm-dynamo/test-module';
|
|
|
4
4
|
import { HttpCallType } from '../../_enums/http/http-call-type.enum';
|
|
5
5
|
import { DynamoNTS_EndpointParams } from '../../_models/dynamo-nts-endpoint-params';
|
|
6
6
|
import { DynamoNTS_Controller } from '../../_services/dynamo-nts-controller.service';
|
|
7
|
+
import { DynamoNTS_GlobalService } from '../app-extended.index';
|
|
7
8
|
|
|
8
9
|
export class TestController extends DynamoNTS_Controller {
|
|
9
10
|
|
|
@@ -97,7 +98,9 @@ export class TestController extends DynamoNTS_Controller {
|
|
|
97
98
|
async (req: Request, res: Response) => {
|
|
98
99
|
|
|
99
100
|
res.send({
|
|
100
|
-
status: 'ready'
|
|
101
|
+
status: 'ready',
|
|
102
|
+
version: DynamoNTS_GlobalService.params.version,
|
|
103
|
+
upTime: DynamoNTS_GlobalService.upTime,
|
|
101
104
|
});
|
|
102
105
|
}
|
|
103
106
|
]
|
|
@@ -127,10 +127,12 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
127
127
|
super();
|
|
128
128
|
|
|
129
129
|
try {
|
|
130
|
-
|
|
130
|
+
this.socketServices = this.getSocketServices();
|
|
131
|
+
|
|
132
|
+
if (this.socketServices?.length) {
|
|
131
133
|
this.setSocketSecurity();
|
|
132
134
|
|
|
133
|
-
this.
|
|
135
|
+
this.mountSocketServices();
|
|
134
136
|
|
|
135
137
|
if (this.debugLog) console.log(`\nAll sockets setted up.... sockets using security: ${this.socketSecurity}`);
|
|
136
138
|
} else {
|
|
@@ -160,7 +162,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
160
162
|
/**
|
|
161
163
|
*
|
|
162
164
|
*/
|
|
163
|
-
private
|
|
165
|
+
private mountSocketServices(): void {
|
|
164
166
|
let httpSocketServer: Http.Server;
|
|
165
167
|
if (this.socketSecurity !== DynamoNTS_RouteSecurity.secure) {
|
|
166
168
|
if (!this.openExpress) {
|
|
@@ -205,7 +207,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
205
207
|
(mod: DynamoNTS_SocketService<any>) => mod.port === service.port
|
|
206
208
|
);
|
|
207
209
|
|
|
208
|
-
if (1 < existingPorts.length || this.httpPort === service.port || this.httpsPort === service.port) {
|
|
210
|
+
if (1 < existingPorts.length || this.ports.httpPort === service.port || this.ports.httpsPort === service.port) {
|
|
209
211
|
let error = new Error(`PORT DUPLICATION: ${service.port}`);
|
|
210
212
|
let errorStack: string[] = error.stack.split('\n');
|
|
211
213
|
errorStack.splice(1, 4);
|
|
@@ -230,4 +232,9 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
230
232
|
}
|
|
231
233
|
});
|
|
232
234
|
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* MISSING Description (TODO)
|
|
238
|
+
*/
|
|
239
|
+
abstract getSocketServices(): DynamoNTS_SocketService<any>[];
|
|
233
240
|
}
|
|
@@ -12,6 +12,17 @@ import { DynamoNTS_RoutingModule } from './dynamo-nts-routing-module.service';
|
|
|
12
12
|
import { DynamoNTS_EndpointParams } from '../_models/dynamo-nts-endpoint-params';
|
|
13
13
|
import { dynamoNTS_GlobalSettings } from '../_constants';
|
|
14
14
|
import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
15
|
+
import { DynamoNTS_GlobalService, DynamoNTS_GlobalServiceSettings } from './dynamo-nts-global.service';
|
|
16
|
+
|
|
17
|
+
export interface DynamoNTS_CertificationSettings {
|
|
18
|
+
keyPath: FileSystem.PathLike,
|
|
19
|
+
certPath: FileSystem.PathLike,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DynamoNTS_PortSettings {
|
|
23
|
+
httpPort?: number,
|
|
24
|
+
httpsPort?: number,
|
|
25
|
+
}
|
|
15
26
|
|
|
16
27
|
/**
|
|
17
28
|
* This will be the MAIN service of our server project,
|
|
@@ -125,49 +136,26 @@ import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
|
125
136
|
*/
|
|
126
137
|
export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
127
138
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
*
|
|
133
|
-
* this.params = new DynamoNTS_AppParams({
|
|
134
|
-
* name: 'Warbots Server',
|
|
135
|
-
* title: warbotsTitleLog,
|
|
136
|
-
* version: version,
|
|
137
|
-
* dbName: 'warbots',
|
|
138
|
-
* });
|
|
139
|
-
*/
|
|
140
|
-
protected params: DynamoNTS_AppParams;
|
|
139
|
+
private _params: DynamoNTS_AppParams;
|
|
140
|
+
protected get params(): DynamoNTS_AppParams { return this._params; }
|
|
141
141
|
|
|
142
142
|
protected mongoose = Mongoose;
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
private _security: DynamoNTS_RouteSecurity;
|
|
145
|
+
protected get security(): DynamoNTS_RouteSecurity { return this._security; }
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*/
|
|
149
|
-
protected httpPort?: number;
|
|
150
|
-
/**
|
|
151
|
-
* setup this in the setupRoutingModules()
|
|
152
|
-
*/
|
|
153
|
-
protected httpsPort?: number;
|
|
147
|
+
protected _ports: DynamoNTS_PortSettings;
|
|
148
|
+
protected get ports(): DynamoNTS_PortSettings { return this._ports; }
|
|
154
149
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
*/
|
|
158
|
-
protected cert?: {
|
|
159
|
-
keyPath: FileSystem.PathLike,
|
|
160
|
-
certPath: FileSystem.PathLike,
|
|
161
|
-
};
|
|
150
|
+
private _cert?: DynamoNTS_CertificationSettings;
|
|
151
|
+
protected get cert(): DynamoNTS_CertificationSettings { return this._cert; }
|
|
162
152
|
|
|
163
153
|
protected openExpress: Express.Application;
|
|
164
154
|
private secureExpress: Express.Application;
|
|
165
155
|
protected httpsServer: Https.Server;
|
|
166
156
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
*/
|
|
170
|
-
protected routingModules: DynamoNTS_RoutingModule[];
|
|
157
|
+
private _routingModules: DynamoNTS_RoutingModule[];
|
|
158
|
+
protected get routingModules(): DynamoNTS_RoutingModule[] { return this._routingModules; }
|
|
171
159
|
|
|
172
160
|
/**
|
|
173
161
|
* setting this value to true, enables this service debug logs
|
|
@@ -178,30 +166,59 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
178
166
|
super();
|
|
179
167
|
|
|
180
168
|
try {
|
|
181
|
-
this.
|
|
182
|
-
|
|
183
|
-
if (this.
|
|
169
|
+
this._params = this.getAppParams();
|
|
170
|
+
|
|
171
|
+
if (this.overrideDynamoNTSGlobalSettings) {
|
|
172
|
+
this.overrideDynamoNTSGlobalSettings();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
|
|
176
|
+
DynamoNTS_GlobalService.setParams(this.params);
|
|
177
|
+
|
|
178
|
+
this._ports = this.getPortSettings();
|
|
179
|
+
if (this.getCertificationSettings) {
|
|
180
|
+
this._cert = this.getCertificationSettings();
|
|
181
|
+
}
|
|
182
|
+
this._routingModules = this.getRoutingModules();
|
|
183
|
+
|
|
184
|
+
if (this.createEntries) {
|
|
185
|
+
this.createEntries();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
console.log(
|
|
189
|
+
`\n\n\nStarting ${this._params.name}... ` +
|
|
190
|
+
`\nVersion: ${this._params.version}`
|
|
191
|
+
);
|
|
192
|
+
if (this._params.title) {
|
|
193
|
+
console.log(this._params.title);
|
|
194
|
+
}
|
|
184
195
|
|
|
185
196
|
this.startDB();
|
|
186
197
|
|
|
187
|
-
this.
|
|
198
|
+
this.getGlobalServiceCollection();
|
|
188
199
|
this.debugLog = dynamoNTS_GlobalSettings.logSetup;
|
|
189
200
|
|
|
190
|
-
this.
|
|
201
|
+
this.getRoutingModules();
|
|
191
202
|
this.setSecurity();
|
|
192
203
|
|
|
193
|
-
if (
|
|
204
|
+
if (this._routingModules?.length) {
|
|
194
205
|
this.initExpresses();
|
|
195
206
|
this.startExpresses();
|
|
196
207
|
|
|
197
|
-
if (this.
|
|
208
|
+
if (this._security !== DynamoNTS_RouteSecurity.secure) {
|
|
198
209
|
this.mountOpenRoutes();
|
|
199
210
|
}
|
|
200
|
-
if (this.
|
|
211
|
+
if (this._security !== DynamoNTS_RouteSecurity.open && this._cert) {
|
|
201
212
|
this.mountSecureRoutes();
|
|
202
213
|
}
|
|
203
214
|
|
|
204
|
-
if (this.debugLog)
|
|
215
|
+
if (this.debugLog) {
|
|
216
|
+
console.log(`\nRoutes mounted.... server using security: ${this._security}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (this.postProcess) {
|
|
221
|
+
this.postProcess();
|
|
205
222
|
}
|
|
206
223
|
} catch (error) {
|
|
207
224
|
Dynamo_Log.error('\nApplication start failed.\n', error);
|
|
@@ -221,7 +238,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
221
238
|
});
|
|
222
239
|
|
|
223
240
|
this.mongoose.connect(
|
|
224
|
-
this.
|
|
241
|
+
this._params.dbUri,
|
|
225
242
|
{
|
|
226
243
|
useNewUrlParser: true,
|
|
227
244
|
useUnifiedTopology: true
|
|
@@ -233,15 +250,15 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
233
250
|
*
|
|
234
251
|
*/
|
|
235
252
|
private initExpresses() {
|
|
236
|
-
if (this.
|
|
237
|
-
if (!this.httpPort) {
|
|
253
|
+
if (this._security !== DynamoNTS_RouteSecurity.secure) {
|
|
254
|
+
if (!this._ports.httpPort) {
|
|
238
255
|
let errorMsg: string =
|
|
239
256
|
`\nYou have open routes, but httpPort is not set!` +
|
|
240
|
-
`\nsecurity: ${this.
|
|
257
|
+
`\nsecurity: ${this._security}` +
|
|
241
258
|
`\nset httpPort in DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
242
259
|
|
|
243
260
|
errorMsg += '\n\nThe routes setted to use open server:';
|
|
244
|
-
this.
|
|
261
|
+
this._routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
245
262
|
if (module.security != DynamoNTS_RouteSecurity.secure) {
|
|
246
263
|
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using open sever:`;
|
|
247
264
|
module.endpoints.forEach((endpoint: DynamoNTS_EndpointParams) => {
|
|
@@ -264,11 +281,11 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
264
281
|
this.initOpenExpress();
|
|
265
282
|
}
|
|
266
283
|
|
|
267
|
-
if (this.
|
|
268
|
-
if (!this.
|
|
284
|
+
if (this._security !== DynamoNTS_RouteSecurity.open) {
|
|
285
|
+
if (!this._cert || !this._ports.httpsPort) {
|
|
269
286
|
let errorMsg: string =
|
|
270
287
|
`\nYou have secure routes, but the certification paths or httpsPort are not set!` +
|
|
271
|
-
`\nsecurity: ${this.
|
|
288
|
+
`\nsecurity: ${this._security}` +
|
|
272
289
|
`\nset...` +
|
|
273
290
|
`\n httpsPort and` +
|
|
274
291
|
`\n cert: {` +
|
|
@@ -278,7 +295,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
278
295
|
`\nin DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
279
296
|
|
|
280
297
|
errorMsg += '\n\nThe routes setted to use secure server:';
|
|
281
|
-
this.
|
|
298
|
+
this._routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
282
299
|
if (module.security != DynamoNTS_RouteSecurity.open) {
|
|
283
300
|
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using secure sever:`;
|
|
284
301
|
module.endpoints.forEach((endpoint: DynamoNTS_EndpointParams) => {
|
|
@@ -320,8 +337,8 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
320
337
|
this.secureExpress.use(BodyParser.json({ limit: '50mb' }));
|
|
321
338
|
|
|
322
339
|
const options = {
|
|
323
|
-
key: FileSystem.readFileSync(this.
|
|
324
|
-
cert: FileSystem.readFileSync(this.
|
|
340
|
+
key: FileSystem.readFileSync(this._cert.keyPath),
|
|
341
|
+
cert: FileSystem.readFileSync(this._cert.certPath),
|
|
325
342
|
};
|
|
326
343
|
this.httpsServer = Https.createServer(options, this.secureExpress);
|
|
327
344
|
}
|
|
@@ -331,10 +348,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
331
348
|
*/
|
|
332
349
|
private async startExpresses(): Promise<void> {
|
|
333
350
|
try {
|
|
334
|
-
if (this.
|
|
351
|
+
if (this._security !== DynamoNTS_RouteSecurity.open) {
|
|
335
352
|
this.httpsServer
|
|
336
|
-
.listen(this.httpsPort, 'localhost', 0, () => {
|
|
337
|
-
Dynamo_Log.success(`\nHTTPS (secure) server is listening on port ${this.httpsPort}\n`);
|
|
353
|
+
.listen(this._ports.httpsPort, 'localhost', 0, () => {
|
|
354
|
+
Dynamo_Log.success(`\nHTTPS (secure) server is listening on port ${this._ports.httpsPort}\n`);
|
|
338
355
|
})
|
|
339
356
|
.on('error', (error) => {
|
|
340
357
|
Dynamo_Log.error(`\nHTTPS (secure) server ERROR`, error);
|
|
@@ -344,10 +361,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
344
361
|
});
|
|
345
362
|
}
|
|
346
363
|
|
|
347
|
-
if (this.
|
|
364
|
+
if (this._security !== DynamoNTS_RouteSecurity.secure) {
|
|
348
365
|
this.openExpress
|
|
349
|
-
.listen(this.httpPort, () => {
|
|
350
|
-
Dynamo_Log.success(`\nHTTP (-open-) server is listening on port ${this.httpPort}\n`);
|
|
366
|
+
.listen(this._ports.httpPort, () => {
|
|
367
|
+
Dynamo_Log.success(`\nHTTP (-open-) server is listening on port ${this._ports.httpPort}\n`);
|
|
351
368
|
})
|
|
352
369
|
.on('error', (error) => {
|
|
353
370
|
Dynamo_Log.error(`\nHTTP (-open-) server ERROR`, error);
|
|
@@ -365,11 +382,16 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
365
382
|
*
|
|
366
383
|
*/
|
|
367
384
|
private mountSecureRoutes (): void {
|
|
368
|
-
this.
|
|
385
|
+
this._routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
369
386
|
if (module.security !== DynamoNTS_RouteSecurity.open) {
|
|
370
|
-
if (this.debugLog)
|
|
371
|
-
|
|
372
|
-
|
|
387
|
+
if (this.debugLog) {
|
|
388
|
+
console.log(`route mount (secure): ${module.route}`);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const existingRoutes: DynamoNTS_RoutingModule[] = this._routingModules.filter(
|
|
392
|
+
(mod: DynamoNTS_RoutingModule) => mod.route === module.route
|
|
393
|
+
);
|
|
394
|
+
|
|
373
395
|
if (1 < existingRoutes.length) {
|
|
374
396
|
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
375
397
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -387,11 +409,16 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
387
409
|
*
|
|
388
410
|
*/
|
|
389
411
|
private mountOpenRoutes (): void {
|
|
390
|
-
this.
|
|
412
|
+
this._routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
391
413
|
if (module.security !== DynamoNTS_RouteSecurity.secure) {
|
|
392
|
-
if (this.debugLog)
|
|
393
|
-
|
|
394
|
-
|
|
414
|
+
if (this.debugLog) {
|
|
415
|
+
console.log(`route mount (open): ${module.route}`);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const existingRoutes: DynamoNTS_RoutingModule[] = this._routingModules.filter(
|
|
419
|
+
(mod: DynamoNTS_RoutingModule) => mod.route === module.route
|
|
420
|
+
);
|
|
421
|
+
|
|
395
422
|
if (1 < existingRoutes.length) {
|
|
396
423
|
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
397
424
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -408,17 +435,18 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
408
435
|
/**
|
|
409
436
|
*
|
|
410
437
|
*/
|
|
411
|
-
|
|
412
|
-
this.
|
|
413
|
-
if (!this.
|
|
414
|
-
this.
|
|
415
|
-
} else if (this.
|
|
416
|
-
this.
|
|
438
|
+
private setSecurity(): void {
|
|
439
|
+
this._routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
440
|
+
if (!this._security) {
|
|
441
|
+
this._security = module.security;
|
|
442
|
+
} else if (this._security !== module.security) {
|
|
443
|
+
this._security = DynamoNTS_RouteSecurity.both;
|
|
417
444
|
}
|
|
418
445
|
});
|
|
419
446
|
}
|
|
420
447
|
|
|
421
448
|
/**
|
|
449
|
+
* #OUTDATED
|
|
422
450
|
* Setting up App params, and preparing project global settings
|
|
423
451
|
* You must setup app params in this function like this:
|
|
424
452
|
*
|
|
@@ -437,9 +465,15 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
437
465
|
* });
|
|
438
466
|
* }
|
|
439
467
|
*/
|
|
440
|
-
abstract
|
|
468
|
+
abstract getAppParams(): DynamoNTS_AppParams;
|
|
441
469
|
|
|
442
470
|
/**
|
|
471
|
+
* MISSING Description (TODO)
|
|
472
|
+
*/
|
|
473
|
+
abstract overrideDynamoNTSGlobalSettings?(): void;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* #OUTDATED
|
|
443
477
|
* Setting up DBServices
|
|
444
478
|
* You must setup globalServiceCollection and dbServices in this function
|
|
445
479
|
*
|
|
@@ -456,9 +490,20 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
456
490
|
* });
|
|
457
491
|
* }
|
|
458
492
|
*/
|
|
459
|
-
abstract
|
|
493
|
+
abstract getGlobalServiceCollection(): DynamoNTS_GlobalServiceSettings;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* MISSING Description (TODO)
|
|
497
|
+
*/
|
|
498
|
+
abstract getPortSettings(): DynamoNTS_PortSettings;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* MISSING Description (TODO)
|
|
502
|
+
*/
|
|
503
|
+
abstract getCertificationSettings?(): DynamoNTS_CertificationSettings;
|
|
460
504
|
|
|
461
505
|
/**
|
|
506
|
+
* #OUTDATED
|
|
462
507
|
* You must setup endpoints and required services in this function
|
|
463
508
|
*
|
|
464
509
|
* @example
|
|
@@ -492,5 +537,15 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
492
537
|
* ];
|
|
493
538
|
* }
|
|
494
539
|
*/
|
|
495
|
-
abstract
|
|
540
|
+
abstract getRoutingModules(): DynamoNTS_RoutingModule[];
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* MISSING Description (TODO)
|
|
544
|
+
*/
|
|
545
|
+
createEntries?(): void;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* MISSING Description (TODO)
|
|
549
|
+
*/
|
|
550
|
+
postProcess?(): void;
|
|
496
551
|
}
|
|
@@ -104,6 +104,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
104
104
|
* use db-service update instead.
|
|
105
105
|
*
|
|
106
106
|
* @param {string} id
|
|
107
|
+
* (using id from service.data, if not provided)
|
|
107
108
|
* @param dontSetToService
|
|
108
109
|
*
|
|
109
110
|
* @return {T} data: T
|
|
@@ -151,6 +152,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
151
152
|
|
|
152
153
|
/**
|
|
153
154
|
* returns data from database by dependencyId to the service
|
|
155
|
+
* (using id from service.data, if not provided)
|
|
154
156
|
* @param dependencyId
|
|
155
157
|
*/
|
|
156
158
|
async getDataByDependencyId(dependencyId?: string, dontSetToService?: boolean): Promise<T> {
|
|
@@ -475,40 +477,40 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
475
477
|
*/
|
|
476
478
|
async saveData(): Promise<void> {
|
|
477
479
|
try {
|
|
478
|
-
if (this.data._id) {
|
|
479
|
-
//
|
|
480
|
-
|
|
480
|
+
if (!this.data._id && (!this.depKey || !this.data[this.depKey])) {
|
|
481
|
+
// if ID of dependencyID is not present, data not exists, create new data
|
|
482
|
+
this.data = await this.dataDBService.createData(this.data, this.issuer);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// check if already exists
|
|
487
|
+
let dataExists: T = await this.getDataById(null, true);
|
|
488
|
+
if (dataExists) {
|
|
489
|
+
// if data exists do modify
|
|
490
|
+
this.data = await this.dataDBService.modifyData(this.data, this.issuer);
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (this.depKey) {
|
|
495
|
+
if (!this.data[this.depKey]) {
|
|
496
|
+
throw new Dynamo_Error({
|
|
497
|
+
status: 417,
|
|
498
|
+
errorCode: 'NTS-DS0-SD1',
|
|
499
|
+
addECToUserMsg: true,
|
|
500
|
+
message: `saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey})`,
|
|
501
|
+
userMessage: this.defaultErrorUserMsg
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
dataExists = await this.getDataByDependencyId(null, true);
|
|
506
|
+
|
|
481
507
|
if (dataExists) {
|
|
482
508
|
// if data exists do modify
|
|
483
509
|
this.data = await this.dataDBService.modifyData(this.data, this.issuer);
|
|
510
|
+
return;
|
|
484
511
|
} else {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
if (!this.data[this.depKey]) {
|
|
488
|
-
throw new Dynamo_Error({
|
|
489
|
-
status: 417,
|
|
490
|
-
errorCode: 'NTS-DS0-SD1',
|
|
491
|
-
addECToUserMsg: true,
|
|
492
|
-
message: `saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey})`,
|
|
493
|
-
userMessage: this.defaultErrorUserMsg
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
/* const dependencyExists = */
|
|
498
|
-
await this.getDependencyDataDBService().getDataById(this.data[this.depKey]).catch(error => {
|
|
499
|
-
if (error?.errorCode === 'NTS-DBS-GI1') {
|
|
500
|
-
throw new Dynamo_Error({
|
|
501
|
-
status: 417,
|
|
502
|
-
errorCode: 'NTS-DS0-SD2',
|
|
503
|
-
addECToUserMsg: true,
|
|
504
|
-
message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]})`,
|
|
505
|
-
userMessage: this.defaultErrorUserMsg
|
|
506
|
-
});
|
|
507
|
-
} else {
|
|
508
|
-
throw error;
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
/* if (!dependencyExists) {
|
|
512
|
+
await this.getDependencyDataDBService().getDataById(this.data[this.depKey]).catch(error => {
|
|
513
|
+
if (error?.errorCode === 'NTS-DBS-GI1') {
|
|
512
514
|
throw new Dynamo_Error({
|
|
513
515
|
status: 417,
|
|
514
516
|
errorCode: 'NTS-DS0-SD2',
|
|
@@ -516,16 +518,20 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
516
518
|
message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]})`,
|
|
517
519
|
userMessage: this.defaultErrorUserMsg
|
|
518
520
|
});
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
this.data = await this.dataDBService.createData(this.data, this.issuer);
|
|
521
|
+
} else {
|
|
522
|
+
throw error;
|
|
523
|
+
}
|
|
524
|
+
});
|
|
524
525
|
}
|
|
525
|
-
} else {
|
|
526
|
-
// if ID is not present, data not exists, create new data
|
|
527
|
-
this.data = await this.dataDBService.createData(this.data, this.issuer);
|
|
528
526
|
}
|
|
527
|
+
|
|
528
|
+
// if data not exists check that dependency already exists for this
|
|
529
|
+
if (this.depKey) {
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// if data not exists create new data
|
|
533
|
+
this.data = await this.dataDBService.createData(this.data, this.issuer);
|
|
534
|
+
|
|
529
535
|
} catch (error) {
|
|
530
536
|
if (['NTS-DS0-SD1', 'NTS-DS0-SD2'].includes(error?.errorCode)) {
|
|
531
537
|
throw error;
|