@futdevpro/nts-dynamo 1.5.30 → 1.5.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_constants/dynamo-nts-global.settings.d.ts +3 -0
- package/lib/_constants/dynamo-nts-global.settings.d.ts.map +1 -0
- package/lib/_constants/dynamo-nts-global.settings.js +13 -0
- package/lib/_constants/dynamo-nts-global.settings.js.map +1 -0
- package/lib/_constants/index.d.ts +1 -1
- package/lib/_constants/index.d.ts.map +1 -1
- package/lib/_constants/index.js +1 -1
- package/lib/_constants/index.js.map +1 -1
- package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +8 -0
- package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts.map +1 -0
- package/lib/_enums/dynamo-nts-data-service-function.enum.js +15 -0
- package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -0
- package/lib/_enums/dynamo-nts-route-security.enum.d.ts +6 -0
- package/lib/_enums/dynamo-nts-route-security.enum.d.ts.map +1 -0
- package/lib/_enums/dynamo-nts-route-security.enum.js +10 -0
- package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -0
- package/lib/_enums/index.d.ts +2 -2
- package/lib/_enums/index.d.ts.map +1 -1
- package/lib/_enums/index.js +2 -2
- package/lib/_enums/index.js.map +1 -1
- package/lib/_models/dynamo-module-settings.d.ts +0 -6
- package/lib/_models/dynamo-module-settings.d.ts.map +1 -1
- package/lib/_models/dynamo-module-settings.js +9 -2
- package/lib/_models/dynamo-module-settings.js.map +1 -1
- package/lib/_models/dynamo-nts-api-call-params.d.ts +37 -0
- package/lib/_models/dynamo-nts-api-call-params.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-api-call-params.js +29 -0
- package/lib/_models/dynamo-nts-api-call-params.js.map +1 -0
- package/lib/_models/dynamo-nts-app-params.d.ts +18 -0
- package/lib/_models/dynamo-nts-app-params.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-app-params.js +17 -0
- package/lib/_models/dynamo-nts-app-params.js.map +1 -0
- package/lib/_models/dynamo-nts-endpoint-params.d.ts +46 -0
- package/lib/_models/dynamo-nts-endpoint-params.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-endpoint-params.js +117 -0
- package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -0
- package/lib/_models/dynamo-nts-global-settings.d.ts +13 -0
- package/lib/_models/dynamo-nts-global-settings.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-global-settings.js +3 -0
- package/lib/_models/dynamo-nts-global-settings.js.map +1 -0
- package/lib/_models/index.d.ts +4 -4
- package/lib/_models/index.d.ts.map +1 -1
- package/lib/_models/index.js +4 -5
- package/lib/_models/index.js.map +1 -1
- package/lib/_modules/api-service.index.d.ts +3 -3
- package/lib/_modules/api-service.index.d.ts.map +1 -1
- package/lib/_modules/api-service.index.js +3 -3
- package/lib/_modules/api-service.index.js.map +1 -1
- package/lib/_modules/app.index.d.ts +9 -9
- package/lib/_modules/app.index.d.ts.map +1 -1
- package/lib/_modules/app.index.js +9 -9
- package/lib/_modules/app.index.js.map +1 -1
- package/lib/_modules/auth.index.d.ts +2 -2
- package/lib/_modules/auth.index.d.ts.map +1 -1
- package/lib/_modules/auth.index.js +2 -2
- package/lib/_modules/auth.index.js.map +1 -1
- package/lib/_modules/controller.index.d.ts +3 -3
- package/lib/_modules/controller.index.d.ts.map +1 -1
- package/lib/_modules/controller.index.js +3 -3
- package/lib/_modules/controller.index.js.map +1 -1
- package/lib/_modules/data-service.index.d.ts +4 -4
- package/lib/_modules/data-service.index.d.ts.map +1 -1
- package/lib/_modules/data-service.index.js +4 -4
- package/lib/_modules/data-service.index.js.map +1 -1
- package/lib/_modules/email.index.d.ts +2 -2
- package/lib/_modules/email.index.d.ts.map +1 -1
- package/lib/_modules/email.index.js +2 -2
- package/lib/_modules/email.index.js.map +1 -1
- package/lib/_modules/test/custom-data.service.d.ts +2 -2
- package/lib/_modules/test/custom-data.service.d.ts.map +1 -1
- package/lib/_modules/test/custom-data.service.js +2 -2
- package/lib/_modules/test/custom-data.service.js.map +1 -1
- package/lib/_modules/test/get-test-routing-module.d.ts +3 -3
- package/lib/_modules/test/get-test-routing-module.d.ts.map +1 -1
- package/lib/_modules/test/get-test-routing-module.js +2 -2
- package/lib/_modules/test/get-test-routing-module.js.map +1 -1
- package/lib/_modules/test/test-controller.d.ts +2 -2
- package/lib/_modules/test/test-controller.d.ts.map +1 -1
- package/lib/_modules/test/test-controller.js +10 -10
- package/lib/_modules/test/test-controller.js.map +1 -1
- package/lib/_modules/usage/get-usage-routing-module.d.ts +3 -3
- package/lib/_modules/usage/get-usage-routing-module.d.ts.map +1 -1
- package/lib/_modules/usage/get-usage-routing-module.js +2 -2
- package/lib/_modules/usage/get-usage-routing-module.js.map +1 -1
- package/lib/_modules/usage/usage-controller.d.ts +2 -2
- package/lib/_modules/usage/usage-controller.d.ts.map +1 -1
- package/lib/_modules/usage/usage-controller.js +10 -10
- package/lib/_modules/usage/usage-controller.js.map +1 -1
- package/lib/_modules/usage/usage.service.d.ts +2 -2
- package/lib/_modules/usage/usage.service.d.ts.map +1 -1
- package/lib/_modules/usage/usage.service.js +6 -6
- package/lib/_modules/usage/usage.service.js.map +1 -1
- package/lib/_services/dynamo-nts-api.service.d.ts +19 -0
- package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-api.service.js +167 -0
- package/lib/_services/dynamo-nts-api.service.js.map +1 -0
- package/lib/_services/dynamo-nts-app-extended.d.ts +23 -0
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-app-extended.js +92 -0
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -0
- package/lib/_services/dynamo-nts-app.d.ts +130 -0
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-app.js +238 -0
- package/lib/_services/dynamo-nts-app.js.map +1 -0
- package/lib/_services/dynamo-nts-auth.service.d.ts +54 -0
- package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-auth.service.js +46 -0
- package/lib/_services/dynamo-nts-auth.service.js.map +1 -0
- package/lib/_services/dynamo-nts-controller.service.d.ts +14 -0
- package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-controller.service.js +21 -0
- package/lib/_services/dynamo-nts-controller.service.js.map +1 -0
- package/lib/_services/dynamo-nts-data.service.d.ts +54 -0
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-data.service.js +301 -0
- package/lib/_services/dynamo-nts-data.service.js.map +1 -0
- package/lib/_services/dynamo-nts-db-service-collection.service.d.ts +9 -0
- package/lib/_services/dynamo-nts-db-service-collection.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-db-service-collection.service.js +11 -0
- package/lib/_services/dynamo-nts-db-service-collection.service.js.map +1 -0
- package/lib/_services/dynamo-nts-db.service.d.ts +244 -0
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-db.service.js +759 -0
- package/lib/_services/dynamo-nts-db.service.js.map +1 -0
- package/lib/_services/dynamo-nts-email-service-collection.service.d.ts +19 -0
- package/lib/_services/dynamo-nts-email-service-collection.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-email-service-collection.service.js +21 -0
- package/lib/_services/dynamo-nts-email-service-collection.service.js.map +1 -0
- package/lib/_services/dynamo-nts-email.service.d.ts +56 -0
- package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-email.service.js +194 -0
- package/lib/_services/dynamo-nts-email.service.js.map +1 -0
- package/lib/_services/dynamo-nts-global.service.d.ts +62 -0
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-global.service.js +107 -0
- package/lib/_services/dynamo-nts-global.service.js.map +1 -0
- package/lib/_services/dynamo-nts-routing-module.service.d.ts +42 -0
- package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-routing-module.service.js +146 -0
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -0
- package/lib/_services/dynamo-nts-shared.service.d.ts +26 -0
- package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-shared.service.js +63 -0
- package/lib/_services/dynamo-nts-shared.service.js.map +1 -0
- package/lib/_services/dynamo-nts-singleton.service.d.ts +9 -0
- package/lib/_services/dynamo-nts-singleton.service.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-singleton.service.js +19 -0
- package/lib/_services/dynamo-nts-singleton.service.js.map +1 -0
- package/lib/_services/dynamobe-email.service.js +1 -1
- package/lib/_services/index.d.ts +13 -13
- package/lib/_services/index.d.ts.map +1 -1
- package/lib/_services/index.js +13 -13
- package/lib/_services/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +995 -319
- package/package.json +2 -6
- package/src/_constants/dynamo-nts-global.settings.ts +12 -0
- package/src/_constants/index.ts +1 -1
- package/src/_enums/{dynamobe-data-service-function.enum.ts → dynamo-nts-data-service-function.enum.ts} +1 -1
- package/src/_enums/{dynamobe-route-security.enum.ts → dynamo-nts-route-security.enum.ts} +1 -1
- package/src/_enums/index.ts +2 -2
- package/src/_models/dynamo-module-settings.ts +2 -2
- package/src/_models/{dynamobe-api-call-params.ts → dynamo-nts-api-call-params.ts} +1 -1
- package/src/_models/{dynamobe-app-params.ts → dynamo-nts-app-params.ts} +1 -1
- package/src/_models/{dynamobe-endpoint-params.ts → dynamo-nts-endpoint-params.ts} +20 -20
- package/src/_models/dynamo-nts-global-settings.ts +13 -0
- package/src/_models/index.ts +4 -5
- package/src/_modules/api-service.index.ts +3 -3
- package/src/_modules/app.index.ts +9 -9
- package/src/_modules/auth.index.ts +2 -2
- package/src/_modules/controller.index.ts +3 -3
- package/src/_modules/data-service.index.ts +4 -4
- package/src/_modules/email.index.ts +2 -2
- package/src/_modules/test/custom-data.service.ts +2 -2
- package/src/_modules/test/get-test-routing-module.ts +5 -5
- package/src/_modules/test/test-controller.ts +10 -10
- package/src/_modules/usage/get-usage-routing-module.ts +5 -5
- package/src/_modules/usage/usage-controller.ts +12 -12
- package/src/_modules/usage/usage.service.ts +6 -6
- package/src/_services/{dynamobe-api.service.ts → dynamo-nts-api.service.ts} +12 -12
- package/src/_services/dynamo-nts-app-extended.ts +124 -0
- package/src/_services/{dynamobe-app.ts → dynamo-nts-app.ts} +49 -49
- package/src/_services/{dynamobe-auth.service.ts → dynamo-nts-auth.service.ts} +2 -2
- package/src/_services/dynamo-nts-controller.service.ts +28 -0
- package/src/_services/{dynamobe-data.service.ts → dynamo-nts-data.service.ts} +7 -7
- package/src/_services/dynamo-nts-db-service-collection.service.ts +12 -0
- package/src/_services/{dynamobe-db.service.ts → dynamo-nts-db.service.ts} +1 -1
- package/src/_services/{dynamobe-email-service-collection.service.ts → dynamo-nts-email-service-collection.service.ts} +4 -4
- package/src/_services/{dynamobe-email.service.ts → dynamo-nts-email.service.ts} +11 -11
- package/src/_services/{dynamobe-global.service.ts → dynamo-nts-global.service.ts} +24 -24
- package/src/_services/{dynamobe-routing-module.service.ts → dynamo-nts-routing-module.service.ts} +26 -26
- package/src/_services/{dynamobe-shared.service.ts → dynamo-nts-shared.service.ts} +1 -1
- package/src/_services/{dynamobe-singleton.service.ts → dynamo-nts-singleton.service.ts} +1 -1
- package/src/_services/index.ts +13 -13
- package/src/_constants/dynamobe-global.settings.ts +0 -12
- package/src/_models/dynamobe-global-settings.ts +0 -13
- package/src/_services/dynamobe-controller.service.ts +0 -28
- package/src/_services/dynamobe-db-service-collection.service.ts +0 -12
|
@@ -4,13 +4,13 @@ import { DynamoBEError } from '@futdevpro/fsm-dynamo';
|
|
|
4
4
|
|
|
5
5
|
import { HttpCallType } from '../_enums/http/http-call-type.enum';
|
|
6
6
|
import { HttpResponseType } from '../_enums/http/http-response-type.enum';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { DynamoNTS_ApiCallParams } from '../_models/dynamo-nts-api-call-params';
|
|
8
|
+
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
export class
|
|
13
|
+
export class DynamoNTS_ApiService {
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
@@ -19,7 +19,7 @@ export class DynamoBEApiService {
|
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
21
|
public static async startApiCall<T>(
|
|
22
|
-
callParams:
|
|
22
|
+
callParams: DynamoNTS_ApiCallParams,
|
|
23
23
|
inputParams?: {
|
|
24
24
|
pathParams?: {
|
|
25
25
|
[param: string]: string
|
|
@@ -38,7 +38,7 @@ export class DynamoBEApiService {
|
|
|
38
38
|
if (callParams.httpOptions.headers[headerKey]) {
|
|
39
39
|
privateAxiosInstance.defaults.headers.common[headerKey] = callParams.httpOptions.headers[headerKey];
|
|
40
40
|
} else {
|
|
41
|
-
|
|
41
|
+
DynamoNTS_Shared.logError('DYNAMOBE ERROR: \n missing header:', headerKey, '\n\n', new Error());
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -55,11 +55,11 @@ export class DynamoBEApiService {
|
|
|
55
55
|
url = url.replace(`:${pathParamKey}`, inputParams.pathParams[pathParamKey]);
|
|
56
56
|
break;
|
|
57
57
|
default:
|
|
58
|
-
|
|
58
|
+
DynamoNTS_Shared.logError(`DYNAMOBE ERROR: \n wrong path param type: (${pathParamKey}): ${paramType} \n${inputParams.pathParams[pathParamKey]}\nMUST BE string or number\n\n`, new Error());
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
61
|
} else {
|
|
62
|
-
|
|
62
|
+
DynamoNTS_Shared.logError('DYNAMOBE ERROR: \n missing pathParam:', pathParamKey, '\n\n', new Error());
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -128,7 +128,7 @@ export class DynamoBEApiService {
|
|
|
128
128
|
});
|
|
129
129
|
break;
|
|
130
130
|
default:
|
|
131
|
-
|
|
131
|
+
DynamoNTS_Shared.logError('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
|
|
132
132
|
break;
|
|
133
133
|
}
|
|
134
134
|
|
|
@@ -138,16 +138,16 @@ export class DynamoBEApiService {
|
|
|
138
138
|
return a as T;
|
|
139
139
|
}
|
|
140
140
|
} catch (error) {
|
|
141
|
-
|
|
141
|
+
DynamoNTS_Shared.logError(`\nAPI ERRROR: ${callParams?.name} failed...` +
|
|
142
142
|
`\n${callParams?.baseUrl}${callParams?.endPoint}`);
|
|
143
143
|
if (callParams?.httpOptions?.responseType === HttpResponseType.text) {
|
|
144
144
|
error.error = JSON.parse(error.error);
|
|
145
145
|
}
|
|
146
146
|
if (error?.response?.data?.flag === 'DYNAMO-BE ERROR OBJECT') {
|
|
147
|
-
|
|
147
|
+
DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
148
148
|
throw new DynamoBEError(error.response.data);
|
|
149
149
|
} else if (error.code === 'ENOTFOUND') {
|
|
150
|
-
|
|
150
|
+
DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
151
151
|
throw new DynamoBEError({
|
|
152
152
|
status: 404, message: 'DNS error; address cannot be resolved!',
|
|
153
153
|
userMessage: `We encountered a BackEnd API Error, please contact the responsible development team. errorcode: 965-453-300`,
|
|
@@ -160,7 +160,7 @@ export class DynamoBEApiService {
|
|
|
160
160
|
error: error
|
|
161
161
|
});
|
|
162
162
|
} else {
|
|
163
|
-
|
|
163
|
+
DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
|
|
164
164
|
throw error;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
|
|
2
|
+
import * as SocketIO from 'socket.io';
|
|
3
|
+
import * as Http from 'http';
|
|
4
|
+
|
|
5
|
+
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
6
|
+
import { DynamoNTS_RouteSecurity } from '../_enums/dynamo-nts-route-security.enum';
|
|
7
|
+
import { DynamoNTS_App } from './dynamo-nts-app';
|
|
8
|
+
|
|
9
|
+
export class DynamoBESocketModule { // NEW
|
|
10
|
+
security:DynamoNTS_RouteSecurity;
|
|
11
|
+
port:number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This will be the main service of our server project,
|
|
16
|
+
* follow the types and type instructions while setting up your project
|
|
17
|
+
*
|
|
18
|
+
* In this service, there are abstract functions that you will need to implement,
|
|
19
|
+
* where you need to set up the main params for your application.
|
|
20
|
+
*/
|
|
21
|
+
export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
22
|
+
|
|
23
|
+
private openSocketServer: SocketIO.Server;
|
|
24
|
+
/* private secureSocketServer: SocketIO.Server; */
|
|
25
|
+
|
|
26
|
+
protected socketModules: DynamoBESocketModule[];
|
|
27
|
+
|
|
28
|
+
constructor(){
|
|
29
|
+
super();
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
|
|
33
|
+
if (0 < this.socketModules.length) { // NEW
|
|
34
|
+
if (this.security !== DynamoNTS_RouteSecurity.secure) {
|
|
35
|
+
this.initOpenSocketPorts();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
DynamoNTS_Shared.logError('\nExtended Application start failed.\n', error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
private initOpenSocketPorts(): void { // NEW NEED SECURE AS WELL
|
|
47
|
+
const httpSocketServer: Http.Server = Http.createServer(this.openExpress);
|
|
48
|
+
this.openSocketServer = new SocketIO.Server(httpSocketServer);
|
|
49
|
+
|
|
50
|
+
this.socketModules.forEach((module: DynamoBESocketModule) => {
|
|
51
|
+
if (module.security !== DynamoNTS_RouteSecurity.secure) {
|
|
52
|
+
if (this.log) console.log(`socket mount (open): ${module.port}`);
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
const existingPorts: DynamoBESocketModule[] = this.socketModules.filter(
|
|
58
|
+
(mod: DynamoBESocketModule) => mod.port === module.port);
|
|
59
|
+
|
|
60
|
+
if (1 < existingPorts.length || this.httpPort === module.port || this.httpsPort === module.port) {
|
|
61
|
+
let error = new Error(`PORT DUPLICATION: ${module.port}`);
|
|
62
|
+
let errorStack: string[] = error.stack.split('\n');
|
|
63
|
+
errorStack.splice(1, 4);
|
|
64
|
+
error.stack = errorStack.join('\n');
|
|
65
|
+
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const highlight = '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' +
|
|
71
|
+
'\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' +
|
|
72
|
+
'\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' +
|
|
73
|
+
'\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!';
|
|
74
|
+
|
|
75
|
+
this.openSocketServer.on('disconnect', (socket) => {
|
|
76
|
+
console.log(highlight, `\nnew DISCONNECT ALFA: \n\n`, socket);
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
this.openSocketServer.on('new message', (msg) => {
|
|
80
|
+
console.log(highlight, `\nnew MESSAGE ALFA: \n\n`, msg);
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
this.openSocketServer.on('connection', (socket) => {
|
|
84
|
+
console.log(highlight, `\nnew CONNECTION: \n\n`, socket);
|
|
85
|
+
|
|
86
|
+
socket.on('disconnect', (socket) => {
|
|
87
|
+
console.log(highlight, `\nnew DISCONNECT BETA: \n\n`, socket);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
socket.on('new message', (msg) => {
|
|
91
|
+
console.log(highlight, `\nnew MESSAGE BETA: \n\n`, msg);
|
|
92
|
+
});
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
this.openSocketServer.listen(module.port);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
this.openSocketServer.on('disconnect', (socket) => {
|
|
102
|
+
console.log(highlight, `\nnew DISCONNECT ALFA: \n\n`, socket);
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
this.openSocketServer.on('new message', (msg) => {
|
|
106
|
+
console.log(highlight, `\nnew MESSAGE ALFA: \n\n`, msg);
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
this.openSocketServer.on('connection', (socket) => {
|
|
110
|
+
console.log(highlight, `\nnew CONNECTION: \n\n`, socket);
|
|
111
|
+
|
|
112
|
+
socket.on('disconnect', (socket) => {
|
|
113
|
+
console.log(highlight, `\nnew DISCONNECT BETA: \n\n`, socket);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
socket.on('new message', (msg) => {
|
|
117
|
+
console.log(highlight, `\nnew MESSAGE BETA: \n\n`, msg);
|
|
118
|
+
});
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { DynamoNTS_AppParams } from '../_models/dynamo-nts-app-params';
|
|
3
3
|
import Mongoose = require("mongoose");
|
|
4
4
|
import Express = require("express");
|
|
5
5
|
import * as Https from 'https';
|
|
6
6
|
import * as FileSystem from 'fs';
|
|
7
7
|
import * as BodyParser from 'body-parser';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
9
|
+
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
10
|
+
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
11
|
+
import { DynamoNTS_RouteSecurity } from '../_enums/dynamo-nts-route-security.enum';
|
|
12
|
+
import { DynamoNTS_RoutingModule } from './dynamo-nts-routing-module.service';
|
|
13
|
+
import { DynamoNTS_EndpointParams } from '../_models/dynamo-nts-endpoint-params';
|
|
14
|
+
import { dynamoNTS_GlobalSettings } from '../_constants';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* This will be the main service of our server project,
|
|
@@ -20,13 +20,13 @@ import { dynamoBEGlobalSettings } from '../_constants';
|
|
|
20
20
|
* In this service, there are abstract functions that you will need to implement,
|
|
21
21
|
* where you need to set up the main params for your application.
|
|
22
22
|
*/
|
|
23
|
-
export abstract class
|
|
23
|
+
export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
24
24
|
|
|
25
|
-
protected params:
|
|
25
|
+
protected params: DynamoNTS_AppParams;
|
|
26
26
|
|
|
27
27
|
protected mongoose = Mongoose;
|
|
28
28
|
|
|
29
|
-
protected security:
|
|
29
|
+
protected security: DynamoNTS_RouteSecurity;
|
|
30
30
|
|
|
31
31
|
protected httpPort?: number;
|
|
32
32
|
protected httpsPort?: number;
|
|
@@ -38,9 +38,9 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
38
38
|
|
|
39
39
|
private secureExpress: Express.Application;
|
|
40
40
|
private httpsServer: Https.Server;
|
|
41
|
-
|
|
41
|
+
protected openExpress: Express.Application;
|
|
42
42
|
|
|
43
|
-
protected routingModules:
|
|
43
|
+
protected routingModules: DynamoNTS_RoutingModule[];
|
|
44
44
|
|
|
45
45
|
protected log: boolean;
|
|
46
46
|
|
|
@@ -55,7 +55,7 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
55
55
|
this.startDB();
|
|
56
56
|
|
|
57
57
|
this.setGlobalServiceCollection();
|
|
58
|
-
this.log =
|
|
58
|
+
this.log = dynamoNTS_GlobalSettings.logSetup;
|
|
59
59
|
|
|
60
60
|
this.setupRoutingModules();
|
|
61
61
|
this.setSecurity();
|
|
@@ -64,17 +64,17 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
64
64
|
this.initExpresses();
|
|
65
65
|
this.startExpresses();
|
|
66
66
|
|
|
67
|
-
if (this.security !==
|
|
67
|
+
if (this.security !== DynamoNTS_RouteSecurity.secure) {
|
|
68
68
|
this.mountOpenRoutes();
|
|
69
69
|
}
|
|
70
|
-
if (this.security !==
|
|
70
|
+
if (this.security !== DynamoNTS_RouteSecurity.open && this.cert) {
|
|
71
71
|
this.mountSecureRoutes();
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
if (this.log) console.log(`\nRoutes mounted.... server using security: ${this.security}`);
|
|
75
75
|
}
|
|
76
76
|
} catch (error) {
|
|
77
|
-
|
|
77
|
+
DynamoNTS_Shared.logError('\nApplication start failed.\n', error);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -84,10 +84,10 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
84
84
|
private startDB(): void {
|
|
85
85
|
this.mongoose.connection
|
|
86
86
|
.on('error', (error) => {
|
|
87
|
-
|
|
87
|
+
DynamoNTS_Shared.logError('\nUnable to connect to MongoDB server, ERROR: ', error);
|
|
88
88
|
})
|
|
89
89
|
.once('open', () => {
|
|
90
|
-
|
|
90
|
+
DynamoNTS_Shared.logSuccess('\nConnected to MongoDB\n');
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
this.mongoose.connect(
|
|
@@ -103,7 +103,7 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
103
103
|
*
|
|
104
104
|
*/
|
|
105
105
|
private initExpresses() {
|
|
106
|
-
if (this.security !==
|
|
106
|
+
if (this.security !== DynamoNTS_RouteSecurity.secure) {
|
|
107
107
|
if (!this.httpPort) {
|
|
108
108
|
let errorMsg: string =
|
|
109
109
|
`\nYou have open routes, but httpPort is not set!` +
|
|
@@ -111,17 +111,17 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
111
111
|
`\nset httpPort in DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
112
112
|
|
|
113
113
|
errorMsg += '\n\nThe routes setted to use open server:';
|
|
114
|
-
this.routingModules.forEach((module:
|
|
115
|
-
if (module.security !=
|
|
114
|
+
this.routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
115
|
+
if (module.security != DynamoNTS_RouteSecurity.secure) {
|
|
116
116
|
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using open sever:`;
|
|
117
|
-
module.endpoints.forEach((endpoint:
|
|
118
|
-
if (endpoint.security !=
|
|
117
|
+
module.endpoints.forEach((endpoint: DynamoNTS_EndpointParams) => {
|
|
118
|
+
if (endpoint.security != DynamoNTS_RouteSecurity.secure) {
|
|
119
119
|
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
|
-
|
|
124
|
+
DynamoNTS_Shared.logError(errorMsg);
|
|
125
125
|
|
|
126
126
|
let error = new Error('Open routes cannot be established!');
|
|
127
127
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -134,7 +134,7 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
134
134
|
this.initOpenExpress();
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
if (this.security !==
|
|
137
|
+
if (this.security !== DynamoNTS_RouteSecurity.open) {
|
|
138
138
|
if (!this.cert || !this.httpsPort) {
|
|
139
139
|
let errorMsg: string =
|
|
140
140
|
`\nYou have secure routes, but the certification paths or httpsPort are not set!` +
|
|
@@ -148,17 +148,17 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
148
148
|
`\nin DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
149
149
|
|
|
150
150
|
errorMsg += '\n\nThe routes setted to use secure server:';
|
|
151
|
-
this.routingModules.forEach((module:
|
|
152
|
-
if (module.security !=
|
|
151
|
+
this.routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
152
|
+
if (module.security != DynamoNTS_RouteSecurity.open) {
|
|
153
153
|
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using secure sever:`;
|
|
154
|
-
module.endpoints.forEach((endpoint:
|
|
155
|
-
if (endpoint.security !=
|
|
154
|
+
module.endpoints.forEach((endpoint: DynamoNTS_EndpointParams) => {
|
|
155
|
+
if (endpoint.security != DynamoNTS_RouteSecurity.open) {
|
|
156
156
|
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
|
-
|
|
161
|
+
DynamoNTS_Shared.logError(errorMsg);
|
|
162
162
|
|
|
163
163
|
let error = new Error('Secure routes cannot be established!');
|
|
164
164
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -201,33 +201,33 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
201
201
|
*/
|
|
202
202
|
private async startExpresses(): Promise<void> {
|
|
203
203
|
try {
|
|
204
|
-
if (this.security !==
|
|
204
|
+
if (this.security !== DynamoNTS_RouteSecurity.open) {
|
|
205
205
|
this.httpsServer
|
|
206
206
|
.listen(this.httpsPort, 'localhost', 0, () => {
|
|
207
|
-
|
|
207
|
+
DynamoNTS_Shared.logSuccess(`\nHTTPS (secure) server is listening on port ${this.httpsPort}\n`);
|
|
208
208
|
})
|
|
209
209
|
.on('error', (error) => {
|
|
210
|
-
|
|
210
|
+
DynamoNTS_Shared.logError(`\nHTTPS (secure) server ERROR`, error);
|
|
211
211
|
})
|
|
212
212
|
.on('uncaughtException', (ex) => {
|
|
213
|
-
|
|
213
|
+
DynamoNTS_Shared.logWarning(`\nHTTPS (secure) server uncaughtException`, ex);
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
if (this.security !==
|
|
217
|
+
if (this.security !== DynamoNTS_RouteSecurity.secure) {
|
|
218
218
|
this.openExpress
|
|
219
219
|
.listen(this.httpPort, () => {
|
|
220
|
-
|
|
220
|
+
DynamoNTS_Shared.logSuccess(`\nHTTP (-open-) server is listening on port ${this.httpPort}\n`);
|
|
221
221
|
})
|
|
222
222
|
.on('error', (error) => {
|
|
223
|
-
|
|
223
|
+
DynamoNTS_Shared.logError(`\nHTTP (-open-) server ERROR`, error);
|
|
224
224
|
})
|
|
225
225
|
.on('uncaughtException', (ex) => {
|
|
226
|
-
|
|
226
|
+
DynamoNTS_Shared.logWarning(`\nHTTP (-open-) server uncaughtException`, ex);
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
229
|
} catch (error) {
|
|
230
|
-
|
|
230
|
+
DynamoNTS_Shared.logError(`startExpresses failed...`, error);
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
@@ -235,11 +235,11 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
235
235
|
*
|
|
236
236
|
*/
|
|
237
237
|
private mountSecureRoutes (): void {
|
|
238
|
-
this.routingModules.forEach((module:
|
|
239
|
-
if (module.security !==
|
|
238
|
+
this.routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
239
|
+
if (module.security !== DynamoNTS_RouteSecurity.open) {
|
|
240
240
|
if (this.log) console.log(`route mount (secure): ${module.route}`);
|
|
241
|
-
const existingRoutes:
|
|
242
|
-
(mod:
|
|
241
|
+
const existingRoutes: DynamoNTS_RoutingModule[] = this.routingModules.filter(
|
|
242
|
+
(mod: DynamoNTS_RoutingModule) => mod.route === module.route);
|
|
243
243
|
if (1 < existingRoutes.length) {
|
|
244
244
|
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
245
245
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -257,11 +257,11 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
257
257
|
*
|
|
258
258
|
*/
|
|
259
259
|
private mountOpenRoutes (): void {
|
|
260
|
-
this.routingModules.forEach((module:
|
|
261
|
-
if (module.security !==
|
|
260
|
+
this.routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
261
|
+
if (module.security !== DynamoNTS_RouteSecurity.secure) {
|
|
262
262
|
if (this.log) console.log(`route mount (open): ${module.route}`);
|
|
263
|
-
const existingRoutes:
|
|
264
|
-
(mod:
|
|
263
|
+
const existingRoutes: DynamoNTS_RoutingModule[] = this.routingModules.filter(
|
|
264
|
+
(mod: DynamoNTS_RoutingModule) => mod.route === module.route);
|
|
265
265
|
if (1 < existingRoutes.length) {
|
|
266
266
|
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
267
267
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -279,11 +279,11 @@ export abstract class DynamoBEApp extends DynamoBESingletonService {
|
|
|
279
279
|
*
|
|
280
280
|
*/
|
|
281
281
|
private setSecurity(): void {
|
|
282
|
-
this.routingModules.forEach((module:
|
|
282
|
+
this.routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
283
283
|
if (!this.security) {
|
|
284
284
|
this.security = module.security;
|
|
285
285
|
} else if (this.security !== module.security) {
|
|
286
|
-
this.security =
|
|
286
|
+
this.security = DynamoNTS_RouteSecurity.both;
|
|
287
287
|
}
|
|
288
288
|
});
|
|
289
289
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { NextFunction, Request, Response } from 'express';
|
|
3
3
|
import { DynamoBEError } from '@futdevpro/fsm-dynamo';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Extend this class as an Auth Service implementation
|
|
@@ -17,7 +17,7 @@ import { DynamoBESingletonService } from './dynamobe-singleton.service';
|
|
|
17
17
|
* }
|
|
18
18
|
* ...
|
|
19
19
|
*/
|
|
20
|
-
export abstract class
|
|
20
|
+
export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* this function returns the 'authorization' header from the Request,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { DynamoNTS_EndpointParams } from '../_models/dynamo-nts-endpoint-params';
|
|
4
|
+
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
5
|
+
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export abstract class DynamoNTS_Controller extends DynamoNTS_SingletonService {
|
|
11
|
+
|
|
12
|
+
endpoints: DynamoNTS_EndpointParams[];
|
|
13
|
+
|
|
14
|
+
protected constructor(){
|
|
15
|
+
super();
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
this.setupEndpoints();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
DynamoNTS_Shared.logError(`DynamoBEController ERROR setup failed:`, error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* You must setup endpoints and required services in this function
|
|
26
|
+
*/
|
|
27
|
+
abstract setupEndpoints(): void
|
|
28
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import { Metadata, DynamoBEDataParams, DynamoBEDataPropertyParams, DynamoBEError } from '@futdevpro/fsm-dynamo';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { DynamoNTS_DBService } from './dynamo-nts-db.service';
|
|
5
|
+
import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
|
|
6
6
|
|
|
7
|
-
export class
|
|
8
|
-
dataDBService:
|
|
7
|
+
export class DynamoNTS_DataService<T extends Metadata> {
|
|
8
|
+
dataDBService: DynamoNTS_DBService<T>;
|
|
9
9
|
data: T;
|
|
10
10
|
dataList: T[] = [];
|
|
11
11
|
issuer?: string;
|
|
@@ -21,7 +21,7 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
21
21
|
dataParams: DynamoBEDataParams,
|
|
22
22
|
issuer?: string,
|
|
23
23
|
) {
|
|
24
|
-
this.dataDBService =
|
|
24
|
+
this.dataDBService = DynamoNTS_GlobalService.getDBService<T>(dataParams);
|
|
25
25
|
this.data = data;
|
|
26
26
|
this.dataParams = dataParams;
|
|
27
27
|
// this.dataModelParams = dataParams.modelParams;
|
|
@@ -277,9 +277,9 @@ export class DynamoBEDataService<T extends Metadata> {
|
|
|
277
277
|
*
|
|
278
278
|
* @returns
|
|
279
279
|
*/
|
|
280
|
-
getDependencyDataDBService():
|
|
280
|
+
getDependencyDataDBService(): DynamoNTS_DBService<any> {
|
|
281
281
|
if (this.depDBServiceKey) {
|
|
282
|
-
return
|
|
282
|
+
return DynamoNTS_GlobalService.getDBService(this.dataParams);
|
|
283
283
|
} else {
|
|
284
284
|
throw new DynamoBEError({
|
|
285
285
|
status: 501, message: 'getDependencyDataDBService was unsuccessful, service key not setted up!',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import { DynamoNTS_DBService } from './dynamo-nts-db.service';
|
|
3
|
+
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export class DynamoNTS_DBServiceCollection extends DynamoNTS_SingletonService {
|
|
9
|
+
|
|
10
|
+
[service: string]: DynamoNTS_DBService<any>;
|
|
11
|
+
|
|
12
|
+
}
|
|
@@ -6,7 +6,7 @@ import { Metadata, DynamoBEDataParams, DynamoBEDataPropertyParams, DynamoBEError
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
export class
|
|
9
|
+
export class DynamoNTS_DBService<T extends Metadata> {
|
|
10
10
|
dataModel = mongoose.model(this.dataParams.dbName, this.getSchema());
|
|
11
11
|
|
|
12
12
|
private depDataName: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { DynamoNTS_EmailService } from './dynamo-nts-email.service';
|
|
3
|
+
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Extend this class as an Email Service Collection implementation
|
|
@@ -15,8 +15,8 @@ import { DynamoBESingletonService } from './dynamobe-singleton.service';
|
|
|
15
15
|
* }
|
|
16
16
|
* ...
|
|
17
17
|
*/
|
|
18
|
-
export class
|
|
18
|
+
export class DynamoNTS_EmailServiceCollection extends DynamoNTS_SingletonService {
|
|
19
19
|
|
|
20
|
-
[service: string]:
|
|
20
|
+
[service: string]: DynamoNTS_EmailService;
|
|
21
21
|
|
|
22
22
|
}
|