@futdevpro/nts-dynamo 1.5.30 → 1.5.32

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.
Files changed (198) hide show
  1. package/lib/_constants/dynamo-nts-global.settings.d.ts +3 -0
  2. package/lib/_constants/dynamo-nts-global.settings.d.ts.map +1 -0
  3. package/lib/_constants/dynamo-nts-global.settings.js +13 -0
  4. package/lib/_constants/dynamo-nts-global.settings.js.map +1 -0
  5. package/lib/_constants/index.d.ts +1 -1
  6. package/lib/_constants/index.d.ts.map +1 -1
  7. package/lib/_constants/index.js +1 -1
  8. package/lib/_constants/index.js.map +1 -1
  9. package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +8 -0
  10. package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts.map +1 -0
  11. package/lib/_enums/dynamo-nts-data-service-function.enum.js +15 -0
  12. package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -0
  13. package/lib/_enums/dynamo-nts-route-security.enum.d.ts +6 -0
  14. package/lib/_enums/dynamo-nts-route-security.enum.d.ts.map +1 -0
  15. package/lib/_enums/dynamo-nts-route-security.enum.js +10 -0
  16. package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -0
  17. package/lib/_enums/index.d.ts +2 -2
  18. package/lib/_enums/index.d.ts.map +1 -1
  19. package/lib/_enums/index.js +2 -2
  20. package/lib/_enums/index.js.map +1 -1
  21. package/lib/_models/dynamo-module-settings.d.ts +0 -6
  22. package/lib/_models/dynamo-module-settings.d.ts.map +1 -1
  23. package/lib/_models/dynamo-module-settings.js +9 -2
  24. package/lib/_models/dynamo-module-settings.js.map +1 -1
  25. package/lib/_models/dynamo-nts-api-call-params.d.ts +37 -0
  26. package/lib/_models/dynamo-nts-api-call-params.d.ts.map +1 -0
  27. package/lib/_models/dynamo-nts-api-call-params.js +29 -0
  28. package/lib/_models/dynamo-nts-api-call-params.js.map +1 -0
  29. package/lib/_models/dynamo-nts-app-params.d.ts +18 -0
  30. package/lib/_models/dynamo-nts-app-params.d.ts.map +1 -0
  31. package/lib/_models/dynamo-nts-app-params.js +17 -0
  32. package/lib/_models/dynamo-nts-app-params.js.map +1 -0
  33. package/lib/_models/dynamo-nts-endpoint-params.d.ts +46 -0
  34. package/lib/_models/dynamo-nts-endpoint-params.d.ts.map +1 -0
  35. package/lib/_models/dynamo-nts-endpoint-params.js +117 -0
  36. package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -0
  37. package/lib/_models/dynamo-nts-global-settings.d.ts +13 -0
  38. package/lib/_models/dynamo-nts-global-settings.d.ts.map +1 -0
  39. package/lib/_models/dynamo-nts-global-settings.js +3 -0
  40. package/lib/_models/dynamo-nts-global-settings.js.map +1 -0
  41. package/lib/_models/index.d.ts +4 -4
  42. package/lib/_models/index.d.ts.map +1 -1
  43. package/lib/_models/index.js +4 -5
  44. package/lib/_models/index.js.map +1 -1
  45. package/lib/_modules/api-service.index.d.ts +3 -3
  46. package/lib/_modules/api-service.index.d.ts.map +1 -1
  47. package/lib/_modules/api-service.index.js +3 -3
  48. package/lib/_modules/api-service.index.js.map +1 -1
  49. package/lib/_modules/app.index.d.ts +9 -9
  50. package/lib/_modules/app.index.d.ts.map +1 -1
  51. package/lib/_modules/app.index.js +9 -9
  52. package/lib/_modules/app.index.js.map +1 -1
  53. package/lib/_modules/auth.index.d.ts +2 -2
  54. package/lib/_modules/auth.index.d.ts.map +1 -1
  55. package/lib/_modules/auth.index.js +2 -2
  56. package/lib/_modules/auth.index.js.map +1 -1
  57. package/lib/_modules/controller.index.d.ts +3 -3
  58. package/lib/_modules/controller.index.d.ts.map +1 -1
  59. package/lib/_modules/controller.index.js +3 -3
  60. package/lib/_modules/controller.index.js.map +1 -1
  61. package/lib/_modules/data-service.index.d.ts +4 -4
  62. package/lib/_modules/data-service.index.d.ts.map +1 -1
  63. package/lib/_modules/data-service.index.js +4 -4
  64. package/lib/_modules/data-service.index.js.map +1 -1
  65. package/lib/_modules/email.index.d.ts +2 -2
  66. package/lib/_modules/email.index.d.ts.map +1 -1
  67. package/lib/_modules/email.index.js +2 -2
  68. package/lib/_modules/email.index.js.map +1 -1
  69. package/lib/_modules/test/custom-data.service.d.ts +2 -2
  70. package/lib/_modules/test/custom-data.service.d.ts.map +1 -1
  71. package/lib/_modules/test/custom-data.service.js +2 -2
  72. package/lib/_modules/test/custom-data.service.js.map +1 -1
  73. package/lib/_modules/test/get-test-routing-module.d.ts +3 -3
  74. package/lib/_modules/test/get-test-routing-module.d.ts.map +1 -1
  75. package/lib/_modules/test/get-test-routing-module.js +2 -2
  76. package/lib/_modules/test/get-test-routing-module.js.map +1 -1
  77. package/lib/_modules/test/test-controller.d.ts +2 -2
  78. package/lib/_modules/test/test-controller.d.ts.map +1 -1
  79. package/lib/_modules/test/test-controller.js +10 -10
  80. package/lib/_modules/test/test-controller.js.map +1 -1
  81. package/lib/_modules/usage/get-usage-routing-module.d.ts +3 -3
  82. package/lib/_modules/usage/get-usage-routing-module.d.ts.map +1 -1
  83. package/lib/_modules/usage/get-usage-routing-module.js +2 -2
  84. package/lib/_modules/usage/get-usage-routing-module.js.map +1 -1
  85. package/lib/_modules/usage/usage-controller.d.ts +2 -2
  86. package/lib/_modules/usage/usage-controller.d.ts.map +1 -1
  87. package/lib/_modules/usage/usage-controller.js +10 -10
  88. package/lib/_modules/usage/usage-controller.js.map +1 -1
  89. package/lib/_modules/usage/usage.service.d.ts +2 -2
  90. package/lib/_modules/usage/usage.service.d.ts.map +1 -1
  91. package/lib/_modules/usage/usage.service.js +10 -10
  92. package/lib/_modules/usage/usage.service.js.map +1 -1
  93. package/lib/_services/dynamo-nts-api.service.d.ts +19 -0
  94. package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -0
  95. package/lib/_services/dynamo-nts-api.service.js +167 -0
  96. package/lib/_services/dynamo-nts-api.service.js.map +1 -0
  97. package/lib/_services/dynamo-nts-app-extended.d.ts +23 -0
  98. package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -0
  99. package/lib/_services/dynamo-nts-app-extended.js +92 -0
  100. package/lib/_services/dynamo-nts-app-extended.js.map +1 -0
  101. package/lib/_services/dynamo-nts-app.d.ts +130 -0
  102. package/lib/_services/dynamo-nts-app.d.ts.map +1 -0
  103. package/lib/_services/dynamo-nts-app.js +238 -0
  104. package/lib/_services/dynamo-nts-app.js.map +1 -0
  105. package/lib/_services/dynamo-nts-auth.service.d.ts +54 -0
  106. package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -0
  107. package/lib/_services/dynamo-nts-auth.service.js +46 -0
  108. package/lib/_services/dynamo-nts-auth.service.js.map +1 -0
  109. package/lib/_services/dynamo-nts-controller.service.d.ts +14 -0
  110. package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -0
  111. package/lib/_services/dynamo-nts-controller.service.js +21 -0
  112. package/lib/_services/dynamo-nts-controller.service.js.map +1 -0
  113. package/lib/_services/dynamo-nts-data.service.d.ts +54 -0
  114. package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -0
  115. package/lib/_services/dynamo-nts-data.service.js +301 -0
  116. package/lib/_services/dynamo-nts-data.service.js.map +1 -0
  117. package/lib/_services/dynamo-nts-db-service-collection.service.d.ts +9 -0
  118. package/lib/_services/dynamo-nts-db-service-collection.service.d.ts.map +1 -0
  119. package/lib/_services/dynamo-nts-db-service-collection.service.js +11 -0
  120. package/lib/_services/dynamo-nts-db-service-collection.service.js.map +1 -0
  121. package/lib/_services/dynamo-nts-db.service.d.ts +244 -0
  122. package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -0
  123. package/lib/_services/dynamo-nts-db.service.js +759 -0
  124. package/lib/_services/dynamo-nts-db.service.js.map +1 -0
  125. package/lib/_services/dynamo-nts-email-service-collection.service.d.ts +19 -0
  126. package/lib/_services/dynamo-nts-email-service-collection.service.d.ts.map +1 -0
  127. package/lib/_services/dynamo-nts-email-service-collection.service.js +21 -0
  128. package/lib/_services/dynamo-nts-email-service-collection.service.js.map +1 -0
  129. package/lib/_services/dynamo-nts-email.service.d.ts +56 -0
  130. package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -0
  131. package/lib/_services/dynamo-nts-email.service.js +194 -0
  132. package/lib/_services/dynamo-nts-email.service.js.map +1 -0
  133. package/lib/_services/dynamo-nts-global.service.d.ts +62 -0
  134. package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -0
  135. package/lib/_services/dynamo-nts-global.service.js +107 -0
  136. package/lib/_services/dynamo-nts-global.service.js.map +1 -0
  137. package/lib/_services/dynamo-nts-routing-module.service.d.ts +42 -0
  138. package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -0
  139. package/lib/_services/dynamo-nts-routing-module.service.js +146 -0
  140. package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -0
  141. package/lib/_services/dynamo-nts-shared.service.d.ts +26 -0
  142. package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -0
  143. package/lib/_services/dynamo-nts-shared.service.js +63 -0
  144. package/lib/_services/dynamo-nts-shared.service.js.map +1 -0
  145. package/lib/_services/dynamo-nts-singleton.service.d.ts +9 -0
  146. package/lib/_services/dynamo-nts-singleton.service.d.ts.map +1 -0
  147. package/lib/_services/dynamo-nts-singleton.service.js +19 -0
  148. package/lib/_services/dynamo-nts-singleton.service.js.map +1 -0
  149. package/lib/_services/dynamobe-db.service.js +1 -1
  150. package/lib/_services/dynamobe-email.service.js +1 -1
  151. package/lib/_services/index.d.ts +13 -13
  152. package/lib/_services/index.d.ts.map +1 -1
  153. package/lib/_services/index.js +13 -13
  154. package/lib/_services/index.js.map +1 -1
  155. package/lib/tsconfig.tsbuildinfo +1041 -365
  156. package/package.json +4 -7
  157. package/src/_constants/dynamo-nts-global.settings.ts +12 -0
  158. package/src/_constants/index.ts +1 -1
  159. package/src/_enums/{dynamobe-data-service-function.enum.ts → dynamo-nts-data-service-function.enum.ts} +1 -1
  160. package/src/_enums/{dynamobe-route-security.enum.ts → dynamo-nts-route-security.enum.ts} +1 -1
  161. package/src/_enums/index.ts +2 -2
  162. package/src/_models/dynamo-module-settings.ts +2 -2
  163. package/src/_models/{dynamobe-api-call-params.ts → dynamo-nts-api-call-params.ts} +1 -1
  164. package/src/_models/{dynamobe-app-params.ts → dynamo-nts-app-params.ts} +1 -1
  165. package/src/_models/{dynamobe-endpoint-params.ts → dynamo-nts-endpoint-params.ts} +20 -20
  166. package/src/_models/dynamo-nts-global-settings.ts +13 -0
  167. package/src/_models/index.ts +4 -5
  168. package/src/_modules/api-service.index.ts +3 -3
  169. package/src/_modules/app.index.ts +9 -9
  170. package/src/_modules/auth.index.ts +2 -2
  171. package/src/_modules/controller.index.ts +3 -3
  172. package/src/_modules/data-service.index.ts +4 -4
  173. package/src/_modules/email.index.ts +2 -2
  174. package/src/_modules/test/custom-data.service.ts +2 -2
  175. package/src/_modules/test/get-test-routing-module.ts +5 -5
  176. package/src/_modules/test/test-controller.ts +10 -10
  177. package/src/_modules/usage/get-usage-routing-module.ts +5 -5
  178. package/src/_modules/usage/usage-controller.ts +12 -12
  179. package/src/_modules/usage/usage.service.ts +11 -11
  180. package/src/_services/{dynamobe-api.service.ts → dynamo-nts-api.service.ts} +16 -16
  181. package/src/_services/dynamo-nts-app-extended.ts +124 -0
  182. package/src/_services/{dynamobe-app.ts → dynamo-nts-app.ts} +49 -49
  183. package/src/_services/{dynamobe-auth.service.ts → dynamo-nts-auth.service.ts} +5 -5
  184. package/src/_services/dynamo-nts-controller.service.ts +28 -0
  185. package/src/_services/{dynamobe-data.service.ts → dynamo-nts-data.service.ts} +29 -29
  186. package/src/_services/dynamo-nts-db-service-collection.service.ts +12 -0
  187. package/src/_services/{dynamobe-db.service.ts → dynamo-nts-db.service.ts} +33 -33
  188. package/src/_services/{dynamobe-email-service-collection.service.ts → dynamo-nts-email-service-collection.service.ts} +4 -4
  189. package/src/_services/{dynamobe-email.service.ts → dynamo-nts-email.service.ts} +16 -16
  190. package/src/_services/{dynamobe-global.service.ts → dynamo-nts-global.service.ts} +27 -27
  191. package/src/_services/{dynamobe-routing-module.service.ts → dynamo-nts-routing-module.service.ts} +30 -30
  192. package/src/_services/{dynamobe-shared.service.ts → dynamo-nts-shared.service.ts} +2 -2
  193. package/src/_services/{dynamobe-singleton.service.ts → dynamo-nts-singleton.service.ts} +1 -1
  194. package/src/_services/index.ts +13 -13
  195. package/src/_constants/dynamobe-global.settings.ts +0 -12
  196. package/src/_models/dynamobe-global-settings.ts +0 -13
  197. package/src/_services/dynamobe-controller.service.ts +0 -28
  198. package/src/_services/dynamobe-db-service-collection.service.ts +0 -12
@@ -1,16 +1,16 @@
1
1
 
2
2
  import * as Axios from 'axios';
3
- import { DynamoBEError } from '@futdevpro/fsm-dynamo';
3
+ import { DynamoNTS_Error } 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 { DynamoBEApiCallParams } from '../_models/dynamobe-api-call-params';
8
- import { DBE_Shared } from './dynamobe-shared.service';
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 DynamoBEApiService {
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: DynamoBEApiCallParams,
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
- DBE_Shared.logError('DYNAMOBE ERROR: \n missing header:', headerKey, '\n\n', new Error());
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
- DBE_Shared.logError(`DYNAMOBE ERROR: \n wrong path param type: (${pathParamKey}): ${paramType} \n${inputParams.pathParams[pathParamKey]}\nMUST BE string or number\n\n`, new Error());
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
- DBE_Shared.logError('DYNAMOBE ERROR: \n missing pathParam:', pathParamKey, '\n\n', new Error());
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
- DBE_Shared.logError('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
131
+ DynamoNTS_Shared.logError('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
132
132
  break;
133
133
  }
134
134
 
@@ -138,29 +138,29 @@ export class DynamoBEApiService {
138
138
  return a as T;
139
139
  }
140
140
  } catch (error) {
141
- DBE_Shared.logError(`\nAPI ERRROR: ${callParams?.name} failed...` +
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
- DBE_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
148
- throw new DynamoBEError(error.response.data);
147
+ DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
148
+ throw new DynamoNTS_Error(error.response.data);
149
149
  } else if (error.code === 'ENOTFOUND') {
150
- DBE_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
151
- throw new DynamoBEError({
150
+ DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
151
+ throw new DynamoNTS_Error({
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`,
154
154
  error: error
155
155
  });
156
156
  } else if (error.config && error.message) {
157
- throw new DynamoBEError({
157
+ throw new DynamoNTS_Error({
158
158
  status: +error.message.substring(error.message.length - 4, 3),
159
159
  userMessage: `We encountered a BackEnd API Error, please contact the responsible development team. errorcode: 965-453-303`,
160
160
  error: error
161
161
  });
162
162
  } else {
163
- DBE_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
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 { DynamoBEAppParams } from '../_models/dynamobe-app-params';
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 { DBE_Shared } from './dynamobe-shared.service';
10
- import { DynamoBESingletonService } from './dynamobe-singleton.service';
11
- import { DynamoBERouteSecurity } from '../_enums/dynamobe-route-security.enum';
12
- import { DynamoBERoutingModule } from './dynamobe-routing-module.service';
13
- import { DynamoBEEndpointParams } from '../_models/dynamobe-endpoint-params';
14
- import { dynamoBEGlobalSettings } from '../_constants';
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 DynamoBEApp extends DynamoBESingletonService {
23
+ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
24
24
 
25
- protected params: DynamoBEAppParams;
25
+ protected params: DynamoNTS_AppParams;
26
26
 
27
27
  protected mongoose = Mongoose;
28
28
 
29
- protected security: DynamoBERouteSecurity;
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
- private openExpress: Express.Application;
41
+ protected openExpress: Express.Application;
42
42
 
43
- protected routingModules: DynamoBERoutingModule[];
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 = dynamoBEGlobalSettings.logSetup;
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 !== DynamoBERouteSecurity.secure) {
67
+ if (this.security !== DynamoNTS_RouteSecurity.secure) {
68
68
  this.mountOpenRoutes();
69
69
  }
70
- if (this.security !== DynamoBERouteSecurity.open && this.cert) {
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
- DBE_Shared.logError('\nApplication start failed.\n', error);
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
- DBE_Shared.logError('\nUnable to connect to MongoDB server, ERROR: ', error);
87
+ DynamoNTS_Shared.logError('\nUnable to connect to MongoDB server, ERROR: ', error);
88
88
  })
89
89
  .once('open', () => {
90
- DBE_Shared.logSuccess('\nConnected to MongoDB\n');
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 !== DynamoBERouteSecurity.secure) {
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: DynamoBERoutingModule) => {
115
- if (module.security != DynamoBERouteSecurity.secure) {
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: DynamoBEEndpointParams) => {
118
- if (endpoint.security != DynamoBERouteSecurity.secure) {
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
- DBE_Shared.logError(errorMsg);
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 !== DynamoBERouteSecurity.open) {
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: DynamoBERoutingModule) => {
152
- if (module.security != DynamoBERouteSecurity.open) {
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: DynamoBEEndpointParams) => {
155
- if (endpoint.security != DynamoBERouteSecurity.open) {
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
- DBE_Shared.logError(errorMsg);
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 !== DynamoBERouteSecurity.open) {
204
+ if (this.security !== DynamoNTS_RouteSecurity.open) {
205
205
  this.httpsServer
206
206
  .listen(this.httpsPort, 'localhost', 0, () => {
207
- DBE_Shared.logSuccess(`\nHTTPS (secure) server is listening on port ${this.httpsPort}\n`);
207
+ DynamoNTS_Shared.logSuccess(`\nHTTPS (secure) server is listening on port ${this.httpsPort}\n`);
208
208
  })
209
209
  .on('error', (error) => {
210
- DBE_Shared.logError(`\nHTTPS (secure) server ERROR`, error);
210
+ DynamoNTS_Shared.logError(`\nHTTPS (secure) server ERROR`, error);
211
211
  })
212
212
  .on('uncaughtException', (ex) => {
213
- DBE_Shared.logWarning(`\nHTTPS (secure) server uncaughtException`, ex);
213
+ DynamoNTS_Shared.logWarning(`\nHTTPS (secure) server uncaughtException`, ex);
214
214
  });
215
215
  }
216
216
 
217
- if (this.security !== DynamoBERouteSecurity.secure) {
217
+ if (this.security !== DynamoNTS_RouteSecurity.secure) {
218
218
  this.openExpress
219
219
  .listen(this.httpPort, () => {
220
- DBE_Shared.logSuccess(`\nHTTP (-open-) server is listening on port ${this.httpPort}\n`);
220
+ DynamoNTS_Shared.logSuccess(`\nHTTP (-open-) server is listening on port ${this.httpPort}\n`);
221
221
  })
222
222
  .on('error', (error) => {
223
- DBE_Shared.logError(`\nHTTP (-open-) server ERROR`, error);
223
+ DynamoNTS_Shared.logError(`\nHTTP (-open-) server ERROR`, error);
224
224
  })
225
225
  .on('uncaughtException', (ex) => {
226
- DBE_Shared.logWarning(`\nHTTP (-open-) server uncaughtException`, ex);
226
+ DynamoNTS_Shared.logWarning(`\nHTTP (-open-) server uncaughtException`, ex);
227
227
  });
228
228
  }
229
229
  } catch (error) {
230
- DBE_Shared.logError(`startExpresses failed...`, error);
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: DynamoBERoutingModule) => {
239
- if (module.security !== DynamoBERouteSecurity.open) {
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: DynamoBERoutingModule[] = this.routingModules.filter(
242
- (mod: DynamoBERoutingModule) => mod.route === module.route);
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: DynamoBERoutingModule) => {
261
- if (module.security !== DynamoBERouteSecurity.secure) {
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: DynamoBERoutingModule[] = this.routingModules.filter(
264
- (mod: DynamoBERoutingModule) => mod.route === module.route);
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: DynamoBERoutingModule) => {
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 = DynamoBERouteSecurity.both;
286
+ this.security = DynamoNTS_RouteSecurity.both;
287
287
  }
288
288
  });
289
289
  }
@@ -1,8 +1,8 @@
1
1
 
2
2
  import { NextFunction, Request, Response } from 'express';
3
- import { DynamoBEError } from '@futdevpro/fsm-dynamo';
3
+ import { DynamoNTS_Error } from '@futdevpro/fsm-dynamo';
4
4
 
5
- import { DynamoBESingletonService } from './dynamobe-singleton.service';
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 DynamoBEAuthService extends DynamoBESingletonService {
20
+ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
21
21
 
22
22
  /**
23
23
  * this function returns the 'authorization' header from the Request,
@@ -29,14 +29,14 @@ export abstract class DynamoBEAuthService extends DynamoBESingletonService {
29
29
  static getTokenFromRequest(req: Request): string {
30
30
  const authHeader = req.headers['authorization'];
31
31
  if (!authHeader) {
32
- throw new DynamoBEError({
32
+ throw new DynamoNTS_Error({
33
33
  message: 'AuthHeader missing!',
34
34
  userMessage: `We encountered a BackEnd Auth Error, please contact the responsible development team. errorcode: 007-636-500`,
35
35
  });
36
36
  }
37
37
  const token = authHeader.split(' ')[1];
38
38
  if (!token) {
39
- throw new DynamoBEError({
39
+ throw new DynamoNTS_Error({
40
40
  message: 'Token missing!',
41
41
  userMessage: `We encountered a BackEnd Auth Error, please contact the responsible development team. errorcode: 007-636-501`,
42
42
  });
@@ -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
+ }