@futdevpro/nts-dynamo 1.5.55 → 1.5.60

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 (127) hide show
  1. package/README.md +123 -0
  2. package/lib/_enums/data-model-type.enum.d.ts +7 -0
  3. package/lib/_enums/data-model-type.enum.d.ts.map +1 -1
  4. package/lib/_enums/data-model-type.enum.js +7 -0
  5. package/lib/_enums/data-model-type.enum.js.map +1 -1
  6. package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +5 -0
  7. package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts.map +1 -1
  8. package/lib/_enums/dynamo-nts-data-service-function.enum.js +5 -1
  9. package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -1
  10. package/lib/_enums/dynamo-nts-route-security.enum.d.ts +6 -0
  11. package/lib/_enums/dynamo-nts-route-security.enum.d.ts.map +1 -1
  12. package/lib/_enums/dynamo-nts-route-security.enum.js +6 -0
  13. package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -1
  14. package/lib/_enums/dynamo-nts-socket-security.enum.d.ts +6 -0
  15. package/lib/_enums/dynamo-nts-socket-security.enum.d.ts.map +1 -1
  16. package/lib/_enums/dynamo-nts-socket-security.enum.js +6 -0
  17. package/lib/_enums/dynamo-nts-socket-security.enum.js.map +1 -1
  18. package/lib/_enums/http/http-call-type.enum.d.ts +4 -0
  19. package/lib/_enums/http/http-call-type.enum.d.ts.map +1 -1
  20. package/lib/_enums/http/http-call-type.enum.js +4 -0
  21. package/lib/_enums/http/http-call-type.enum.js.map +1 -1
  22. package/lib/_enums/predefined-data-types.enum.d.ts +3 -0
  23. package/lib/_enums/predefined-data-types.enum.d.ts.map +1 -1
  24. package/lib/_enums/predefined-data-types.enum.js +3 -0
  25. package/lib/_enums/predefined-data-types.enum.js.map +1 -1
  26. package/lib/_models/dynamo-nts-api-call-params.d.ts +61 -2
  27. package/lib/_models/dynamo-nts-api-call-params.d.ts.map +1 -1
  28. package/lib/_models/dynamo-nts-api-call-params.js +24 -7
  29. package/lib/_models/dynamo-nts-api-call-params.js.map +1 -1
  30. package/lib/_models/dynamo-nts-app-params.d.ts +33 -1
  31. package/lib/_models/dynamo-nts-app-params.d.ts.map +1 -1
  32. package/lib/_models/dynamo-nts-app-params.js +1 -1
  33. package/lib/_models/dynamo-nts-app-params.js.map +1 -1
  34. package/lib/_models/dynamo-nts-endpoint-params.d.ts +36 -1
  35. package/lib/_models/dynamo-nts-endpoint-params.d.ts.map +1 -1
  36. package/lib/_models/dynamo-nts-endpoint-params.js +15 -13
  37. package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
  38. package/lib/_models/dynamo-nts-global-settings.d.ts +31 -0
  39. package/lib/_models/dynamo-nts-global-settings.d.ts.map +1 -1
  40. package/lib/_models/dynamo-nts-routing-module-settings.d.ts +10 -1
  41. package/lib/_models/dynamo-nts-routing-module-settings.d.ts.map +1 -1
  42. package/lib/_models/dynamo-nts-socket-dictionary.d.ts +3 -0
  43. package/lib/_models/dynamo-nts-socket-dictionary.d.ts.map +1 -1
  44. package/lib/_models/dynamo-nts-socket-dictionary.js +3 -0
  45. package/lib/_models/dynamo-nts-socket-dictionary.js.map +1 -1
  46. package/lib/_models/dynamo-nts-socket-event-params.d.ts +1 -1
  47. package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
  48. package/lib/_models/dynamo-nts-socket-event-params.js +3 -3
  49. package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
  50. package/lib/_models/dynamo-nts-socket-service-params.d.ts +1 -1
  51. package/lib/_models/dynamo-nts-socket-service-params.d.ts.map +1 -1
  52. package/lib/_models/dynamo-nts-socket-service-params.js +3 -3
  53. package/lib/_models/dynamo-nts-socket-service-params.js.map +1 -1
  54. package/lib/_modules/usage/usage.service.js +1 -1
  55. package/lib/_modules/usage/usage.service.js.map +1 -1
  56. package/lib/_services/dynamo-nts-api.service.d.ts +17 -2
  57. package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -1
  58. package/lib/_services/dynamo-nts-api.service.js +21 -12
  59. package/lib/_services/dynamo-nts-api.service.js.map +1 -1
  60. package/lib/_services/dynamo-nts-app-extended.d.ts +10 -1
  61. package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
  62. package/lib/_services/dynamo-nts-app-extended.js +8 -8
  63. package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
  64. package/lib/_services/dynamo-nts-app.d.ts +30 -3
  65. package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
  66. package/lib/_services/dynamo-nts-app.js +19 -19
  67. package/lib/_services/dynamo-nts-app.js.map +1 -1
  68. package/lib/_services/dynamo-nts-auth.service.d.ts +4 -4
  69. package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
  70. package/lib/_services/dynamo-nts-auth.service.js +2 -1
  71. package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
  72. package/lib/_services/dynamo-nts-controller.service.d.ts +55 -0
  73. package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
  74. package/lib/_services/dynamo-nts-controller.service.js +2 -2
  75. package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
  76. package/lib/_services/dynamo-nts-data.service.d.ts +13 -1
  77. package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
  78. package/lib/_services/dynamo-nts-data.service.js +23 -9
  79. package/lib/_services/dynamo-nts-data.service.js.map +1 -1
  80. package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
  81. package/lib/_services/dynamo-nts-db.service.js +2 -1
  82. package/lib/_services/dynamo-nts-db.service.js.map +1 -1
  83. package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
  84. package/lib/_services/dynamo-nts-email.service.js +28 -23
  85. package/lib/_services/dynamo-nts-email.service.js.map +1 -1
  86. package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
  87. package/lib/_services/dynamo-nts-global.service.js +3 -3
  88. package/lib/_services/dynamo-nts-global.service.js.map +1 -1
  89. package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
  90. package/lib/_services/dynamo-nts-routing-module.service.js +3 -3
  91. package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
  92. package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
  93. package/lib/_services/dynamo-nts-socket.service.js +3 -3
  94. package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
  95. package/lib/tsconfig.tsbuildinfo +1 -1
  96. package/package.json +13 -13
  97. package/src/_assets/dynamo-nts-128.png +0 -0
  98. package/src/_assets/dynamo-nts-256.png +0 -0
  99. package/src/_assets/dynamo-nts-512.png +0 -0
  100. package/src/_assets/dynamo-nts-64.png +0 -0
  101. package/src/_enums/data-model-type.enum.ts +7 -0
  102. package/src/_enums/dynamo-nts-data-service-function.enum.ts +5 -1
  103. package/src/_enums/dynamo-nts-route-security.enum.ts +6 -0
  104. package/src/_enums/dynamo-nts-socket-security.enum.ts +6 -0
  105. package/src/_enums/http/http-call-type.enum.ts +4 -0
  106. package/src/_enums/predefined-data-types.enum.ts +3 -0
  107. package/src/_models/dynamo-nts-api-call-params.ts +74 -14
  108. package/src/_models/dynamo-nts-app-params.ts +33 -1
  109. package/src/_models/dynamo-nts-endpoint-params.ts +49 -14
  110. package/src/_models/dynamo-nts-global-settings.ts +31 -0
  111. package/src/_models/dynamo-nts-routing-module-settings.ts +10 -1
  112. package/src/_models/dynamo-nts-socket-dictionary.ts +3 -0
  113. package/src/_models/dynamo-nts-socket-event-params.ts +3 -3
  114. package/src/_models/dynamo-nts-socket-service-params.ts +3 -3
  115. package/src/_modules/usage/usage.service.ts +2 -2
  116. package/src/_services/dynamo-nts-api.service.ts +26 -13
  117. package/src/_services/dynamo-nts-app-extended.ts +17 -8
  118. package/src/_services/dynamo-nts-app.ts +47 -20
  119. package/src/_services/dynamo-nts-auth.service.ts +7 -5
  120. package/src/_services/dynamo-nts-controller.service.ts +57 -2
  121. package/src/_services/dynamo-nts-data.service.ts +22 -10
  122. package/src/_services/dynamo-nts-db.service.ts +3 -1
  123. package/src/_services/dynamo-nts-email.service.ts +36 -24
  124. package/src/_services/dynamo-nts-global.service.ts +3 -4
  125. package/src/_services/dynamo-nts-routing-module.service.ts +5 -4
  126. package/src/_services/dynamo-nts-socket.service.ts +5 -4
  127. package/src/version.json +0 -2
@@ -2,22 +2,74 @@
2
2
  import { HttpCallType } from "../_enums/http/http-call-type.enum";
3
3
  import { HttpResponseType } from "../_enums/http/http-response-type.enum";
4
4
 
5
+ /**
6
+ * API call params,
7
+ * such as
8
+ * type (HttpCallType),
9
+ * endpoint,
10
+ * and other options as httpOptions
11
+ */
5
12
  export class DynamoNTS_ApiCallParams {
13
+ /**
14
+ * name the call to be able to identify it when debugging
15
+ */
6
16
  name: string;
17
+ /**
18
+ * type of the call as; HttpCallType .get, .post, ...ect
19
+ */
7
20
  type: HttpCallType;
21
+ /**
22
+ * the endpoint of the API, without the baseUrl:
23
+ * '/user/get/:userId',
24
+ * where the parts starting with ':', will be used as pathParam
25
+ */
8
26
  baseUrl: string;
27
+ /**
28
+ * baseUrl of the API;
29
+ * 'https://futdevpro.hu/api'
30
+ */
9
31
  endPoint: string;
10
32
 
33
+ /**
34
+ * if this value is true, the call will return the full HTTP call response in raw
35
+ */
11
36
  getFullResponse: boolean;
37
+ /**
38
+ * this setting will be passed to the axios http call
39
+ */
12
40
  httpOptions: any;
13
41
 
14
42
  constructor(
43
+ /**
44
+ * set of options necessary for setting up an API call
45
+ */
15
46
  set: {
47
+ /**
48
+ * name the call to be able to identify it when debugging
49
+ */
16
50
  name: string,
51
+ /**
52
+ * set type as; HttpCallType .get, .post, ...ect
53
+ */
17
54
  type: HttpCallType,
55
+ /**
56
+ * the endpoint of the API, without the baseUrl:
57
+ * '/user/get/:userId',
58
+ * where the parts starting with ':', will be used as pathParam
59
+ */
18
60
  endPoint: string,
61
+ /**
62
+ * baseUrl of the API;
63
+ * 'https://futdevpro.hu/api'
64
+ */
19
65
  baseUrl: string,
66
+ /**
67
+ * setting this value to true, will return the full HTTP call response in raw
68
+ */
20
69
  getFullResponse?: boolean,
70
+ /**
71
+ * this setting will pass any kind of http setting used by the axios http messaging package
72
+ */
21
73
  httpOptions?: HttpOptions,
22
74
  }
23
75
  ) {
@@ -34,6 +86,12 @@ export class DynamoNTS_ApiCallParams {
34
86
  }
35
87
  }
36
88
 
89
+ /**
90
+ * basic axios HttpsOptions,
91
+ *
92
+ * learn more on axios package....
93
+ * TOD: link package documentations
94
+ */
37
95
  export class HttpOptions {
38
96
  responseType?: HttpResponseType;
39
97
  headers?: {
@@ -43,19 +101,21 @@ export class HttpOptions {
43
101
  reportProgress?: boolean;
44
102
  withCredentials?: boolean;
45
103
 
46
- constructor(options: {
47
- responseType?: HttpResponseType,
48
- headers?: {
49
- [header: string]: string | string[];
50
- },
51
- observe?: 'body',
52
- reportProgress?: boolean,
53
- withCredentials?: boolean
54
- }) {
55
- this.responseType = options.responseType;
56
- this.headers = options.headers;
57
- this.observe = options.observe;
58
- this.reportProgress = options.reportProgress;
59
- this.withCredentials = options.withCredentials;
104
+ constructor(
105
+ set: {
106
+ responseType?: HttpResponseType,
107
+ headers?: {
108
+ [header: string]: string | string[];
109
+ },
110
+ observe?: 'body',
111
+ reportProgress?: boolean,
112
+ withCredentials?: boolean
113
+ }
114
+ ) {
115
+ this.responseType = set.responseType;
116
+ this.headers = set.headers;
117
+ this.observe = set.observe;
118
+ this.reportProgress = set.reportProgress;
119
+ this.withCredentials = set.withCredentials;
60
120
  }
61
121
  }
@@ -1,20 +1,52 @@
1
1
 
2
2
  /**
3
- *
3
+ * This will hold and set the basic settings of an application
4
4
  */
5
5
  export class DynamoNTS_AppParams {
6
+ /**
7
+ * name of the application
8
+ */
6
9
  name: string;
10
+ /**
11
+ * title will be shown on the start of the application
12
+ */
7
13
  title: string;
14
+ /**
15
+ * version of the application
16
+ */
8
17
  version: string;
18
+ /**
19
+ * name of your MongoDB table
20
+ */
9
21
  dbUri: string;
22
+ /**
23
+ * mongoDB uri, by default, its: `mongodb://localhost:27017/${this.dbName}`
24
+ */
10
25
  dbName: string;
11
26
 
12
27
  constructor(
13
28
  set: {
29
+ /**
30
+ * name the application
31
+ */
14
32
  name: string,
33
+ /**
34
+ * you can set a big f*in title to show on the start of the application
35
+ */
15
36
  title?: string,
37
+ /**
38
+ * you should set the version,
39
+ * probably, you should set from the package.json as follows:
40
+ * import { version } from '../package.json';
41
+ */
16
42
  version: string,
43
+ /**
44
+ * You need to name your MongoDB table
45
+ */
17
46
  dbName: string,
47
+ /**
48
+ * you can change the mongoDB uri here. by default, its: `mongodb://localhost:27017/${this.dbName}`
49
+ */
18
50
  dbUri?: string,
19
51
  }
20
52
  ) {
@@ -4,13 +4,14 @@ import { NextFunction, Request, Response } from 'express';
4
4
 
5
5
  import { HttpCallType } from '../_enums/http/http-call-type.enum';
6
6
  import { DynamoNTS_RouteSecurity } from '../_enums/dynamo-nts-route-security.enum';
7
- import { DynamoNTS_Shared } from '../_services/dynamo-nts-shared.service';
8
7
  import { DynamoNTS_GlobalService } from '../_services/dynamo-nts-global.service';
9
8
  import { dynamoNTS_GlobalSettings } from '../_constants';
10
- import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
9
+ import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
11
10
 
12
11
  /**
13
- *
12
+ * High level endpoint for API
13
+ * used for specific events such as saving or getting data,
14
+ * triggering events, logging in or out, and much more
14
15
  */
15
16
  export class DynamoNTS_EndpointParams{
16
17
  name: string;
@@ -30,23 +31,56 @@ export class DynamoNTS_EndpointParams{
30
31
 
31
32
  constructor(
32
33
  set: {
34
+ /**
35
+ * naming the endpoint will help to follow events on service
36
+ */
33
37
  name: string,
38
+ /**
39
+ * security settings for API, different security paths will need different handlers
40
+ *
41
+ * open; http, secure; https or both
42
+ */
34
43
  security?: DynamoNTS_RouteSecurity,
35
44
 
45
+ /**
46
+ * define basic Http Call Type such as; get, post, put, patch, delete
47
+ */
36
48
  type: HttpCallType,
49
+ /**
50
+ * set endpoint here, without baseUrl and route module path
51
+ *
52
+ * like: '/get-user/:userId'
53
+ */
37
54
  endpoint: string,
38
55
 
56
+ /**
57
+ * preprocesses are the functions you need to run before the actual function,
58
+ * such as authentications
59
+ */
39
60
  preProcessess?: ((req: Request, res: Response, next: NextFunction) => Promise<void>)[],
61
+ /**
62
+ * the actual tasks to run,
63
+ * the last one should contain the res.send(); execution to send response on API requests
64
+ */
40
65
  tasks: ((req: Request, res: Response, issuer?: string) => Promise<void>)[],
41
66
 
67
+ /**
68
+ * this flag will enable the debug logs on this endpoint
69
+ */
42
70
  logRequest?: boolean,
71
+ /**
72
+ * this flag will enable the debug logs on this endpoint's requests
73
+ */
43
74
  logRequestsContent?: boolean,
75
+ /**
76
+ * this flag will enable detailed debug logs on this endpoint's requests
77
+ */
44
78
  logResponseContent?: boolean,
45
79
  }
46
80
  ) {
47
81
  try {
48
- this.name = set.name ? set.name : set.endpoint;
49
- this.security = set.security ? set.security : dynamoNTS_GlobalSettings.defaultRouteSecurity;
82
+ this.name = set.name ?? set.endpoint;
83
+ this.security = set.security ?? dynamoNTS_GlobalSettings.defaultRouteSecurity;
50
84
 
51
85
  this.type = set.type;
52
86
  this.endpoint = set.endpoint;
@@ -60,12 +94,13 @@ export class DynamoNTS_EndpointParams{
60
94
  userMessage: 'We encountered an unhandled Server Error, please contact the responsible development team.'
61
95
  });
62
96
  }
97
+
63
98
  let pathParts: string[] = this.endpoint.split('/');
64
99
  pathParts = pathParts.filter((part: string) => part[0] === ':');
65
100
  pathParts = pathParts.map((part: string) => part = part.replace(':', ''));
66
101
  this.pathParams = pathParts;
67
102
 
68
- this.preProcessess = set.preProcessess ? set.preProcessess : [];
103
+ this.preProcessess = set.preProcessess ?? [];
69
104
  this.tasks = set.tasks;
70
105
 
71
106
  this.logRequest = set.logRequest !== undefined ? set.logRequest : dynamoNTS_GlobalSettings.logRequest;
@@ -76,7 +111,7 @@ export class DynamoNTS_EndpointParams{
76
111
  this.preProcessess.unshift(this.getPreLog());
77
112
  }
78
113
  } catch (error) {
79
- DynamoNTS_Shared.logError(
114
+ Dynamo_Log.logError(
80
115
  `\nEndpoint params setup failed: name: '${set.name}' (security: ${set.security}) endpoint: ${set.endpoint}\nERROR:\n`, error);
81
116
  throw error;
82
117
  }
@@ -131,10 +166,10 @@ export class DynamoNTS_EndpointParams{
131
166
 
132
167
  if (this.logRequest) {
133
168
  if (this.logResponseContent) {
134
- DynamoNTS_Shared.logSuccess(` <<<===== ${this.name} result sent.`);
135
- DynamoNTS_Shared.logSuccess('sorry, the logResponseContent is not implemented yet.');
169
+ Dynamo_Log.logSuccess(` <<<===== ${this.name} result sent.`);
170
+ Dynamo_Log.logSuccess('sorry, the logResponseContent is not implemented yet.');
136
171
  } else {
137
- DynamoNTS_Shared.logSuccess(` <<<===== ${this.name} result sent.`);
172
+ Dynamo_Log.logSuccess(` <<<===== ${this.name} result sent.`);
138
173
  }
139
174
  }
140
175
  } catch (error) {
@@ -149,16 +184,16 @@ export class DynamoNTS_EndpointParams{
149
184
  * @param error
150
185
  */
151
186
  error(res: Response, error): void {
152
- DynamoNTS_Shared.logError(`Endpoint catched an error. ${this.name} (${this.endpoint})\nERROR:`, error, '\n');
187
+ Dynamo_Log.logError(`Endpoint catched an error. ${this.name} (${this.endpoint})\nERROR:`, error, '\n');
153
188
  res.status(error.status ? error.status : 501);
154
189
  res.send(error);
155
190
 
156
191
  if (this.logRequest) {
157
192
  if (this.logResponseContent) {
158
- DynamoNTS_Shared.logError(` <<<===== ${this.name} error sent.`);
159
- DynamoNTS_Shared.logError('sorry, the logResponseContent is not implemented yet.');
193
+ Dynamo_Log.logError(` <<<===== ${this.name} error sent.`);
194
+ Dynamo_Log.logError('sorry, the logResponseContent is not implemented yet.');
160
195
  } else {
161
- DynamoNTS_Shared.logError(` <<<===== ${this.name} error sent.`);
196
+ Dynamo_Log.logError(` <<<===== ${this.name} error sent.`);
162
197
  }
163
198
  }
164
199
  }
@@ -10,17 +10,48 @@ import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.e
10
10
  *
11
11
  */
12
12
  export interface DynamoNTS_GlobalSettings {
13
+ /**
14
+ * this will be used as the main baseUrl for the application,
15
+ * this is not required, but we suggest to use at least a '/api' as base route
16
+ */
13
17
  baseUrl: string;
18
+ /**
19
+ * this sets the default security for routes
20
+ */
14
21
  defaultRouteSecurity: DynamoNTS_RouteSecurity;
22
+ /**
23
+ * this sets the default security for sockets
24
+ */
15
25
  defaultSocketSecurity: DynamoNTS_SocketSecurity;
16
26
 
27
+ /**
28
+ * this setting will enable debug logs for setting up the application
29
+ */
17
30
  logSetup?: boolean;
18
31
 
32
+ /**
33
+ * this is an application wide default setting for route debug logs
34
+ */
19
35
  logRequest?: boolean;
36
+ /**
37
+ * this is an application wide default setting for route debug logs
38
+ */
20
39
  logRequestsContent?: boolean;
40
+ /**
41
+ * this is an application wide default setting for route debug logs
42
+ */
21
43
  logResponseContent?: boolean;
22
44
 
45
+ /**
46
+ * this is an application wide default setting for socket debug logs
47
+ */
23
48
  logMainSocketEvent?: boolean;
49
+ /**
50
+ * this is an application wide default setting for socket debug logs
51
+ */
24
52
  logAllSocketEvent?: boolean;
53
+ /**
54
+ * this is an application wide default setting for socket debug logs
55
+ */
25
56
  logEventContent?: boolean;
26
57
  }
@@ -2,10 +2,19 @@ import { DynamoNTS_RouteSecurity } from '../_enums';
2
2
  import { DynamoNTS_Controller } from '../_services';
3
3
 
4
4
  /**
5
- *
5
+ * This is a main route point handler, which collects a list of controllers for the API
6
6
  */
7
7
  export interface DynamoNTS_RoutingModuleSettings {
8
+ /**
9
+ * main route of the module
10
+ */
8
11
  route: string;
12
+ /**
13
+ * the collection of controllers (sub-routes, with differentlogical parts, to different db elements)
14
+ */
9
15
  controllers: DynamoNTS_Controller[];
16
+ /**
17
+ * securityOverride will be used to create different security for a single module without changing the default security (http/https/both)
18
+ */
10
19
  securityOverride?: DynamoNTS_RouteSecurity;
11
20
  }
@@ -2,6 +2,9 @@
2
2
  import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
3
3
  import * as SocketIO from 'socket.io';
4
4
 
5
+ /**
6
+ * socket handling and clarification is under development
7
+ */
5
8
  export class DynamoNTS_SocketDictionary {
6
9
  issuerId: string;
7
10
  sockets: SocketIO.Socket[];
@@ -1,11 +1,11 @@
1
1
 
2
2
 
3
- import { DynamoNTS_Shared } from '../_services/dynamo-nts-shared.service';
4
3
  import { dynamoNTS_GlobalSettings } from '../_constants';
5
4
  import { DynamoNTS_SocketEvent } from '../_enums/http/socket-event.enum';
5
+ import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
6
6
 
7
7
  /**
8
- *
8
+ * socket handling and clarification is under development
9
9
  */
10
10
  export class DynamoNTS_SocketEventParams<T>{
11
11
  socketName?: string;
@@ -49,7 +49,7 @@ export class DynamoNTS_SocketEventParams<T>{
49
49
  this.preProcessess.unshift(this.getPreLog());
50
50
  }
51
51
  } catch (error) {
52
- DynamoNTS_Shared.logError(
52
+ Dynamo_Log.logError(
53
53
  `\nSocket Event params setup failed (${this.socketName}): ${set.event}`, error);
54
54
  throw error;
55
55
  }
@@ -1,10 +1,10 @@
1
1
 
2
+ import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
2
3
  import { dynamoNTS_GlobalSettings } from '../_constants';
3
4
  import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.enum';
4
- import { DynamoNTS_Shared } from '../_services';
5
5
 
6
6
  /**
7
- *
7
+ * socket handling and clarification is under development
8
8
  */
9
9
  export class DynamoNTS_SocketServiceParams {
10
10
  name: string;
@@ -31,7 +31,7 @@ export class DynamoNTS_SocketServiceParams {
31
31
  if (set.getIdFromSubscrioption) {
32
32
  this.getIdFromSubscrioption = set.getIdFromSubscrioption;
33
33
  if (set.groupActiveSocketsBy) {
34
- DynamoNTS_Shared.logError(
34
+ Dynamo_Log.logError(
35
35
  `setting groupActiveSocketsBy on DynamoNTS_SocketService (${this.name}) won't take effect, ` +
36
36
  `since getIdFromSubscrioption is also setted, so it will be used instead`)
37
37
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { Request } from 'express';
3
- import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
3
+ import { Dynamo_Error, Dynamo_Time } from '@futdevpro/fsm-dynamo';
4
4
  import { Dynamo_UsageSession, usageSessionModelParams, Dynamo_UsageData,
5
5
  Dynamo_DailyUsageData } from '@futdevpro/fsm-dynamo/usage-module';
6
6
 
@@ -46,7 +46,7 @@ export class UsageService extends DynamoNTS_DataService<Dynamo_UsageSession> {
46
46
  async getLastWeekUsage(): Promise<void> {
47
47
  try {
48
48
  await this.dataDBService.find({
49
- sessionStart: { $gte: DynamoNTS_Shared.oneWeekAgo() }
49
+ sessionStart: { $gte: Dynamo_Time.oneWeekAgo() }
50
50
  }).then((res: Dynamo_UsageSession[]) => {
51
51
  this.dataList = res;
52
52
  });
@@ -1,18 +1,19 @@
1
1
 
2
2
  import * as Axios from 'axios';
3
- import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
3
+ import { Dynamo_Error, Dynamo_Log } 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
7
  import { DynamoNTS_ApiCallParams } from '../_models/dynamo-nts-api-call-params';
8
- import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
9
8
 
10
9
  /**
11
- *
10
+ * This predefined Api service contains the basic API call function which can be used in various ways
12
11
  */
13
12
  export class DynamoNTS_ApiService {
14
13
 
15
- static defaultErrorUserMsg = 'We encountered a BackEnd API Error, please contact the responsible development team.';
14
+ static defaultErrorUserMsg =
15
+ `We encountered a BackEnd API Error, ` +
16
+ `\nplease contact the responsible development team.`;
16
17
 
17
18
  /**
18
19
  *
@@ -21,12 +22,24 @@ export class DynamoNTS_ApiService {
21
22
  * @returns
22
23
  */
23
24
  public static async startApiCall<T>(
25
+ /**
26
+ * you must setup the basic api call params with this.
27
+ * follow the instructions in the constructor: new DynamoNTS_ApiCallParams({ ... })
28
+ */
24
29
  callParams: DynamoNTS_ApiCallParams,
30
+ /**
31
+ * you can pass data and other inputs in this section
32
+ */
25
33
  inputParams?: {
26
34
  pathParams?: {
35
+ /**
36
+ * path params setted in endpoint
37
+ */
27
38
  [param: string]: string
28
39
  },
29
- /* queryParams?: object, */
40
+ /**
41
+ * api call's body
42
+ */
30
43
  body?: any
31
44
  }
32
45
  ): Promise<any> {
@@ -40,7 +53,7 @@ export class DynamoNTS_ApiService {
40
53
  if (callParams.httpOptions.headers[headerKey]) {
41
54
  privateAxiosInstance.defaults.headers.common[headerKey] = callParams.httpOptions.headers[headerKey];
42
55
  } else {
43
- DynamoNTS_Shared.logError('DYNAMOBE ERROR: \n missing header:', headerKey, '\n\n', new Error());
56
+ Dynamo_Log.logError('DYNAMOBE ERROR: \n missing header:', headerKey, '\n\n', new Error());
44
57
  }
45
58
  }
46
59
  }
@@ -57,11 +70,11 @@ export class DynamoNTS_ApiService {
57
70
  url = url.replace(`:${pathParamKey}`, inputParams.pathParams[pathParamKey]);
58
71
  break;
59
72
  default:
60
- 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());
73
+ Dynamo_Log.logError(`DYNAMOBE ERROR: \n wrong path param type: (${pathParamKey}): ${paramType} \n${inputParams.pathParams[pathParamKey]}\nMUST BE string or number\n\n`, new Error());
61
74
  break;
62
75
  }
63
76
  } else {
64
- DynamoNTS_Shared.logError('DYNAMOBE ERROR: \n missing pathParam:', pathParamKey, '\n\n', new Error());
77
+ Dynamo_Log.logError('DYNAMOBE ERROR: \n missing pathParam:', pathParamKey, '\n\n', new Error());
65
78
  }
66
79
  }
67
80
  }
@@ -130,7 +143,7 @@ export class DynamoNTS_ApiService {
130
143
  });
131
144
  break;
132
145
  default:
133
- DynamoNTS_Shared.logError('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
146
+ Dynamo_Log.logError('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
134
147
  break;
135
148
  }
136
149
 
@@ -140,7 +153,7 @@ export class DynamoNTS_ApiService {
140
153
  return a as T;
141
154
  }
142
155
  } catch (error) {
143
- DynamoNTS_Shared.logError(`\nAPI ERROR: ${callParams?.name} failed...` +
156
+ Dynamo_Log.logError(`\nAPI ERROR: ${callParams?.name} failed...` +
144
157
  `\n${callParams?.baseUrl}${callParams?.endPoint}`);
145
158
 
146
159
  if (callParams?.httpOptions?.responseType === HttpResponseType.text) {
@@ -148,7 +161,7 @@ export class DynamoNTS_ApiService {
148
161
  }
149
162
 
150
163
  if (error?.response?.data?.flag === 'DYNAMO ERROR OBJECT') {
151
- DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
164
+ Dynamo_Log.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
152
165
 
153
166
  throw new Dynamo_Error({
154
167
  errorCode: 'NTS-API-002',
@@ -158,7 +171,7 @@ export class DynamoNTS_ApiService {
158
171
  error: error.response.data
159
172
  });
160
173
  } else if (error.code === 'ENOTFOUND') {
161
- DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
174
+ Dynamo_Log.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
162
175
 
163
176
  throw new Dynamo_Error({
164
177
  status: 404,
@@ -178,7 +191,7 @@ export class DynamoNTS_ApiService {
178
191
  error
179
192
  });
180
193
  } else {
181
- DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
194
+ Dynamo_Log.logError(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
182
195
 
183
196
  throw error;
184
197
  }
@@ -2,11 +2,11 @@
2
2
  import * as SocketIO from 'socket.io';
3
3
  import * as Http from 'http';
4
4
 
5
- import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
6
5
  import { DynamoNTS_RouteSecurity } from '../_enums/dynamo-nts-route-security.enum';
7
6
  import { DynamoNTS_App } from './dynamo-nts-app';
8
7
  import { DynamoNTS_SocketService } from './dynamo-nts-socket.service';
9
8
  import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.enum';
9
+ import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
10
10
 
11
11
  /**
12
12
  * This will be the MAIN service of our server project,
@@ -27,7 +27,7 @@ import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.e
27
27
  * // Setting up App params, and preparing project global settings
28
28
  * setupAppParams(): void {
29
29
  * this.params = new DynamoNTS_AppParams({
30
- * name: 'Warbots Distribution Server',
30
+ * name: 'Warbots Server',
31
31
  * title: warbotsTitleLog,
32
32
  * version: version,
33
33
  * dbName: 'warbots',
@@ -112,6 +112,15 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
112
112
 
113
113
  private socketSecurity: DynamoNTS_RouteSecurity;
114
114
 
115
+ /**
116
+ * @example
117
+ * // Setting up Sockets
118
+ * this.socketServices = [
119
+ * NotificationService.getInstance(),
120
+ * ChatService.getInstance(),
121
+ * ...
122
+ * ];
123
+ */
115
124
  protected socketServices: DynamoNTS_SocketService<any>[];
116
125
 
117
126
  constructor(){
@@ -123,15 +132,15 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
123
132
 
124
133
  this.setupSocketServices();
125
134
 
126
- if (this.log) console.log(`\nAll sockets setted up.... sockets using security: ${this.socketSecurity}`);
135
+ if (this.debugLog) console.log(`\nAll sockets setted up.... sockets using security: ${this.socketSecurity}`);
127
136
  } else {
128
- DynamoNTS_Shared.logWarning(
137
+ Dynamo_Log.logWarning(
129
138
  '\nNo socketServices setted up while using Extended Application.',
130
139
  '\nYou should use DynamoNTS_App if you don`t need socket services.\n'
131
140
  );
132
141
  }
133
142
  } catch (error) {
134
- DynamoNTS_Shared.logError('\nExtended Application start failed.\n', error, '\n');
143
+ Dynamo_Log.logError('\nExtended Application start failed.\n', error, '\n');
135
144
  }
136
145
  }
137
146
 
@@ -179,7 +188,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
179
188
  errorMsg += `\n ${service.name} (port: ${service.port})`;
180
189
  }
181
190
  });
182
- DynamoNTS_Shared.logError(errorMsg);
191
+ Dynamo_Log.logError(errorMsg);
183
192
 
184
193
  let error = new Error('Secure routes cannot be established!');
185
194
  let errorStack: string[] = error.stack.split('\n');
@@ -206,10 +215,10 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
206
215
  }
207
216
 
208
217
  if (service.security === DynamoNTS_SocketSecurity.open) {
209
- if (this.log) console.log(`\nsocket setup (open): ${service.name}:${service.port}`);
218
+ if (this.debugLog) console.log(`\nsocket setup (open): ${service.name}:${service.port}`);
210
219
  service.setupSocketServer(new SocketIO.Server(httpSocketServer));
211
220
  } else if (service.security === DynamoNTS_SocketSecurity.secure) {
212
- if (this.log) console.log(`\nsocket setup (secure): ${service.name}:${service.port}`);
221
+ if (this.debugLog) console.log(`\nsocket setup (secure): ${service.name}:${service.port}`);
213
222
  service.setupSocketServer(new SocketIO.Server(this.httpsServer));
214
223
  } else {
215
224
  let error = new Error(`INVALID Socket Service security: ${service.security} on ${service.name}`);