@futdevpro/nts-dynamo 1.2.90

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 (179) hide show
  1. package/BuildPackage.bat +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +17 -0
  4. package/lib/_constants/dynamobe-global.settings.d.ts +2 -0
  5. package/lib/_constants/dynamobe-global.settings.d.ts.map +1 -0
  6. package/lib/_constants/dynamobe-global.settings.js +11 -0
  7. package/lib/_enum/data-model-types.enum.d.ts +5 -0
  8. package/lib/_enum/data-model-types.enum.d.ts.map +1 -0
  9. package/lib/_enum/data-model-types.enum.js +9 -0
  10. package/lib/_enum/dynamobe-data-service-function.enum.d.ts +7 -0
  11. package/lib/_enum/dynamobe-data-service-function.enum.d.ts.map +1 -0
  12. package/lib/_enum/dynamobe-data-service-function.enum.js +14 -0
  13. package/lib/_enum/dynamobe-route-security.enum.d.ts +5 -0
  14. package/lib/_enum/dynamobe-route-security.enum.d.ts.map +1 -0
  15. package/lib/_enum/dynamobe-route-security.enum.js +9 -0
  16. package/lib/_enum/http/http-call-type.enum.d.ts +7 -0
  17. package/lib/_enum/http/http-call-type.enum.d.ts.map +1 -0
  18. package/lib/_enum/http/http-call-type.enum.js +11 -0
  19. package/lib/_enum/http/http-response-type.enum.d.ts +6 -0
  20. package/lib/_enum/http/http-response-type.enum.d.ts.map +1 -0
  21. package/lib/_enum/http/http-response-type.enum.js +10 -0
  22. package/lib/_enum/log-style.enum.d.ts +25 -0
  23. package/lib/_enum/log-style.enum.d.ts.map +1 -0
  24. package/lib/_enum/log-style.enum.js +29 -0
  25. package/lib/_enum/predefined-data-types.enum.d.ts +7 -0
  26. package/lib/_enum/predefined-data-types.enum.d.ts.map +1 -0
  27. package/lib/_enum/predefined-data-types.enum.js +11 -0
  28. package/lib/_models/dynamobe-api-call-params.d.ts +34 -0
  29. package/lib/_models/dynamobe-api-call-params.d.ts.map +1 -0
  30. package/lib/_models/dynamobe-api-call-params.js +24 -0
  31. package/lib/_models/dynamobe-app-params.d.ts +14 -0
  32. package/lib/_models/dynamobe-app-params.d.ts.map +1 -0
  33. package/lib/_models/dynamobe-app-params.js +13 -0
  34. package/lib/_models/dynamobe-data-model-params.d.ts +12 -0
  35. package/lib/_models/dynamobe-data-model-params.d.ts.map +1 -0
  36. package/lib/_models/dynamobe-data-model-params.js +14 -0
  37. package/lib/_models/dynamobe-endpoint-control.d.ts +28 -0
  38. package/lib/_models/dynamobe-endpoint-control.d.ts.map +1 -0
  39. package/lib/_models/dynamobe-endpoint-control.js +85 -0
  40. package/lib/_models/dynamobe-global-settings.d.ts +8 -0
  41. package/lib/_models/dynamobe-global-settings.d.ts.map +1 -0
  42. package/lib/_models/dynamobe-global-settings.js +6 -0
  43. package/lib/_models/fullstack-models/control-models/daily-usage-data.d.ts +17 -0
  44. package/lib/_models/fullstack-models/control-models/daily-usage-data.d.ts.map +1 -0
  45. package/lib/_models/fullstack-models/control-models/daily-usage-data.js +21 -0
  46. package/lib/_models/fullstack-models/control-models/dynamobe-data-property-params.d.ts +27 -0
  47. package/lib/_models/fullstack-models/control-models/dynamobe-data-property-params.d.ts.map +1 -0
  48. package/lib/_models/fullstack-models/control-models/dynamobe-data-property-params.js +66 -0
  49. package/lib/_models/fullstack-models/control-models/dynamobe-error.d.ts +17 -0
  50. package/lib/_models/fullstack-models/control-models/dynamobe-error.d.ts.map +1 -0
  51. package/lib/_models/fullstack-models/control-models/dynamobe-error.js +195 -0
  52. package/lib/_models/fullstack-models/control-models/geo-ip-location.d.ts +25 -0
  53. package/lib/_models/fullstack-models/control-models/geo-ip-location.d.ts.map +1 -0
  54. package/lib/_models/fullstack-models/control-models/geo-ip-location.js +2 -0
  55. package/lib/_models/fullstack-models/control-models/usage-action.d.ts +8 -0
  56. package/lib/_models/fullstack-models/control-models/usage-action.d.ts.map +1 -0
  57. package/lib/_models/fullstack-models/control-models/usage-action.js +12 -0
  58. package/lib/_models/fullstack-models/control-models/usage-data.d.ts +13 -0
  59. package/lib/_models/fullstack-models/control-models/usage-data.d.ts.map +1 -0
  60. package/lib/_models/fullstack-models/control-models/usage-data.js +15 -0
  61. package/lib/_models/fullstack-models/data-models/custom-data.d.ts +15 -0
  62. package/lib/_models/fullstack-models/data-models/custom-data.d.ts.map +1 -0
  63. package/lib/_models/fullstack-models/data-models/custom-data.js +23 -0
  64. package/lib/_models/fullstack-models/data-models/metadata.d.ts +16 -0
  65. package/lib/_models/fullstack-models/data-models/metadata.d.ts.map +1 -0
  66. package/lib/_models/fullstack-models/data-models/metadata.js +16 -0
  67. package/lib/_models/fullstack-models/data-models/usage-session.d.ts +33 -0
  68. package/lib/_models/fullstack-models/data-models/usage-session.d.ts.map +1 -0
  69. package/lib/_models/fullstack-models/data-models/usage-session.js +48 -0
  70. package/lib/_modules/test-route/custom-data.service.d.ts +5 -0
  71. package/lib/_modules/test-route/custom-data.service.d.ts.map +1 -0
  72. package/lib/_modules/test-route/custom-data.service.js +12 -0
  73. package/lib/_modules/test-route/test-controller.d.ts +5 -0
  74. package/lib/_modules/test-route/test-controller.d.ts.map +1 -0
  75. package/lib/_modules/test-route/test-controller.js +125 -0
  76. package/lib/_modules/usage-route/usage-controller.d.ts +6 -0
  77. package/lib/_modules/usage-route/usage-controller.d.ts.map +1 -0
  78. package/lib/_modules/usage-route/usage-controller.js +88 -0
  79. package/lib/_modules/usage-route/usage.service.d.ts +18 -0
  80. package/lib/_modules/usage-route/usage.service.d.ts.map +1 -0
  81. package/lib/_modules/usage-route/usage.service.js +110 -0
  82. package/lib/_services/dynamobe-api.service.d.ts +9 -0
  83. package/lib/_services/dynamobe-api.service.d.ts.map +1 -0
  84. package/lib/_services/dynamobe-api.service.js +130 -0
  85. package/lib/_services/dynamobe-app.d.ts +11 -0
  86. package/lib/_services/dynamobe-app.d.ts.map +1 -0
  87. package/lib/_services/dynamobe-app.js +38 -0
  88. package/lib/_services/dynamobe-auth.service.d.ts +25 -0
  89. package/lib/_services/dynamobe-auth.service.d.ts.map +1 -0
  90. package/lib/_services/dynamobe-auth.service.js +24 -0
  91. package/lib/_services/dynamobe-controller.service.d.ts +10 -0
  92. package/lib/_services/dynamobe-controller.service.d.ts.map +1 -0
  93. package/lib/_services/dynamobe-controller.service.js +11 -0
  94. package/lib/_services/dynamobe-data.service.d.ts +51 -0
  95. package/lib/_services/dynamobe-data.service.d.ts.map +1 -0
  96. package/lib/_services/dynamobe-data.service.js +224 -0
  97. package/lib/_services/dynamobe-db-service-collection.service.d.ts +5 -0
  98. package/lib/_services/dynamobe-db-service-collection.service.d.ts.map +1 -0
  99. package/lib/_services/dynamobe-db-service-collection.service.js +7 -0
  100. package/lib/_services/dynamobe-db.service.d.ts +150 -0
  101. package/lib/_services/dynamobe-db.service.d.ts.map +1 -0
  102. package/lib/_services/dynamobe-db.service.js +577 -0
  103. package/lib/_services/dynamobe-email-service-collection.service.d.ts +5 -0
  104. package/lib/_services/dynamobe-email-service-collection.service.d.ts.map +1 -0
  105. package/lib/_services/dynamobe-email-service-collection.service.js +7 -0
  106. package/lib/_services/dynamobe-email.service.d.ts +32 -0
  107. package/lib/_services/dynamobe-email.service.d.ts.map +1 -0
  108. package/lib/_services/dynamobe-email.service.js +144 -0
  109. package/lib/_services/dynamobe-global.service.d.ts +22 -0
  110. package/lib/_services/dynamobe-global.service.d.ts.map +1 -0
  111. package/lib/_services/dynamobe-global.service.js +84 -0
  112. package/lib/_services/dynamobe-routing-module.service.d.ts +25 -0
  113. package/lib/_services/dynamobe-routing-module.service.d.ts.map +1 -0
  114. package/lib/_services/dynamobe-routing-module.service.js +112 -0
  115. package/lib/_services/dynamobe-server.d.ts +31 -0
  116. package/lib/_services/dynamobe-server.d.ts.map +1 -0
  117. package/lib/_services/dynamobe-server.js +179 -0
  118. package/lib/_services/dynamobe-shared.service.d.ts +100 -0
  119. package/lib/_services/dynamobe-shared.service.d.ts.map +1 -0
  120. package/lib/_services/dynamobe-shared.service.js +294 -0
  121. package/lib/_services/dynamobe-singleton.service.d.ts +5 -0
  122. package/lib/_services/dynamobe-singleton.service.d.ts.map +1 -0
  123. package/lib/_services/dynamobe-singleton.service.js +15 -0
  124. package/lib/index-newo.d.ts +0 -0
  125. package/lib/index-newo.d.ts.map +1 -0
  126. package/lib/index-newo.js +71 -0
  127. package/lib/index-old.d.ts +39 -0
  128. package/lib/index-old.js +49 -0
  129. package/lib/index.d.ts +39 -0
  130. package/lib/index.d.ts.map +1 -0
  131. package/lib/index.js +49 -0
  132. package/lib/tsconfig.tsbuildinfo +2080 -0
  133. package/nodemon.json +6 -0
  134. package/package.json +52 -0
  135. package/src/_constants/dynamobe-global.settings.ts +11 -0
  136. package/src/_enum/data-model-types.enum.ts +6 -0
  137. package/src/_enum/dynamobe-data-service-function.enum.ts +11 -0
  138. package/src/_enum/dynamobe-route-security.enum.ts +6 -0
  139. package/src/_enum/http/http-call-type.enum.ts +8 -0
  140. package/src/_enum/http/http-response-type.enum.ts +7 -0
  141. package/src/_enum/log-style.enum.ts +30 -0
  142. package/src/_enum/predefined-data-types.enum.ts +8 -0
  143. package/src/_models/dynamobe-api-call-params.ts +62 -0
  144. package/src/_models/dynamobe-app-params.ts +24 -0
  145. package/src/_models/dynamobe-data-model-params.ts +23 -0
  146. package/src/_models/dynamobe-endpoint-control.ts +127 -0
  147. package/src/_models/dynamobe-global-settings.ts +9 -0
  148. package/src/_models/fullstack-models/control-models/daily-usage-data.ts +34 -0
  149. package/src/_models/fullstack-models/control-models/dynamobe-data-property-params.ts +98 -0
  150. package/src/_models/fullstack-models/control-models/dynamobe-error.ts +207 -0
  151. package/src/_models/fullstack-models/control-models/geo-ip-location.ts +26 -0
  152. package/src/_models/fullstack-models/control-models/usage-action.ts +18 -0
  153. package/src/_models/fullstack-models/control-models/usage-data.ts +26 -0
  154. package/src/_models/fullstack-models/data-models/custom-data.ts +37 -0
  155. package/src/_models/fullstack-models/data-models/metadata.ts +28 -0
  156. package/src/_models/fullstack-models/data-models/usage-session.ts +82 -0
  157. package/src/_modules/test-route/custom-data.service.ts +21 -0
  158. package/src/_modules/test-route/test-controller.ts +136 -0
  159. package/src/_modules/usage-route/usage-controller.ts +114 -0
  160. package/src/_modules/usage-route/usage.service.ts +125 -0
  161. package/src/_services/dynamobe-api.service.ts +135 -0
  162. package/src/_services/dynamobe-app.ts +49 -0
  163. package/src/_services/dynamobe-auth.service.ts +42 -0
  164. package/src/_services/dynamobe-controller.service.ts +20 -0
  165. package/src/_services/dynamobe-data.service.ts +215 -0
  166. package/src/_services/dynamobe-db-service-collection.service.ts +9 -0
  167. package/src/_services/dynamobe-db.service.ts +556 -0
  168. package/src/_services/dynamobe-email-service-collection.service.ts +9 -0
  169. package/src/_services/dynamobe-email.service.ts +169 -0
  170. package/src/_services/dynamobe-global.service.ts +99 -0
  171. package/src/_services/dynamobe-routing-module.service.ts +141 -0
  172. package/src/_services/dynamobe-server.ts +225 -0
  173. package/src/_services/dynamobe-shared.service.ts +320 -0
  174. package/src/_services/dynamobe-singleton.service.ts +16 -0
  175. package/src/index-newo.ts +71 -0
  176. package/src/index.ts +50 -0
  177. package/src/version.json +2 -0
  178. package/tsconfig.app.json +12 -0
  179. package/tsconfig.json +72 -0
@@ -0,0 +1,207 @@
1
+
2
+ // import { Error as MongooseError } from 'mongoose';
3
+
4
+ export class DynamoBEError {
5
+ flag = 'DYNAMO-BE ERROR OBJECT';
6
+ handled: boolean;
7
+ status: number;
8
+ errors: any[] = [];
9
+ error: any;
10
+ // dberrors: MongooseError[] = [];
11
+ messages: string[] = [];
12
+ userMessages: string[] = [];
13
+
14
+ constructor(
15
+ customConstructor: {
16
+ status?: number,
17
+ message?: string,
18
+ messages?: string[],
19
+ userMessage?: string,
20
+ error?: any,
21
+ consoleLog?: boolean,
22
+ }
23
+ ) {
24
+ //console.log('HEREIAM', customConstructor);
25
+ if (customConstructor.status) {
26
+ this.status = customConstructor.status;
27
+ }
28
+ this.status = customConstructor?.error?.status ? customConstructor.error.status : this.status;
29
+
30
+ if (customConstructor?.error?.errors) {
31
+ this.errors = this.errors.concat(customConstructor?.error?.errors);
32
+ }
33
+ /* if (customConstructor?.error?.dberrors) {
34
+ this.dberrors= this.dberrors.concat(customConstructor?.error?.dberrors);
35
+ } */
36
+ if (customConstructor?.error?.messages) {
37
+ this.messages = this.messages.concat(customConstructor?.error?.messages);
38
+ }
39
+ if (customConstructor?.error?.userMessages) {
40
+ this.userMessages = this.userMessages.concat(customConstructor?.error?.userMessages);
41
+ }
42
+
43
+ if (customConstructor.error) {
44
+ if (customConstructor.error instanceof DynamoBEError) {
45
+ this.errors.push(customConstructor.error.error);
46
+ } else {
47
+ if (customConstructor.error.error) {
48
+ this.errors.push(customConstructor.error.error);
49
+ }
50
+ this.errors.push(customConstructor.error);
51
+ }
52
+ /* if (customConstructor.error instanceof MongooseError) {
53
+ this.dberrors.push(customConstructor.error);
54
+ } */
55
+ if (customConstructor.error.message) {
56
+ this.messages.push(customConstructor.error.message);
57
+ }
58
+ if (customConstructor.error.status) {
59
+ this.status = customConstructor.error.status;
60
+ }
61
+ }
62
+ if (customConstructor.message) {
63
+ this.messages.push(customConstructor.message)
64
+ }
65
+ if (customConstructor.messages) {
66
+ this.messages.push(...customConstructor.messages)
67
+ }
68
+ if (customConstructor.userMessage) {
69
+ this.userMessages.push(customConstructor.userMessage)
70
+ }
71
+ if (customConstructor.consoleLog) {
72
+ console.log(this);
73
+ }
74
+ }
75
+ }
76
+
77
+ /*
78
+
79
+ // //
80
+ // RESPONSE STATUS //
81
+ // //
82
+
83
+ 1XX informational response
84
+
85
+ 100 Continue
86
+ 101 Switching Protocols
87
+ 102 Processing
88
+ 103 Early Hints
89
+
90
+
91
+ 2XX success
92
+
93
+ 200 OK
94
+ 201 Created
95
+ 202 Accepted
96
+ 203 Non-Authoritative Information
97
+ 204 No Content
98
+ 205 Reset Content
99
+ 206 Partial Content
100
+ 207 Multi-Status
101
+ 208 Already Reported
102
+ 226 IM Used
103
+
104
+
105
+ 3XX redirection
106
+
107
+ 300 Multiple Choices
108
+ 301 Moved Permanently
109
+ 302 Found
110
+ 303 See Other
111
+ 304 Not Modified
112
+ 305 Use Proxy
113
+ 306 Switch Proxy
114
+ 307 Temporary Redirect
115
+ 308 Permanent Redirect
116
+
117
+
118
+ 4XX client errors
119
+
120
+ 400 Bad Request
121
+ 401 Unauthorized
122
+ 402 Payment Required
123
+ 403 Forbidden
124
+ 404 Not Found
125
+ 405 Method Not Allowed
126
+ 406 Not Acceptable
127
+ 407 Proxy Authentication Required
128
+ 408 Request Timeout
129
+ 409 Conflict
130
+ 410 Gone
131
+ 411 Length Required
132
+ 412 Precondition Failed
133
+ 413 Payload Too Large
134
+ 414 URI Too Long
135
+ 415 Unsupported Media Type
136
+ 416 Range Not Satisfiable
137
+ 417 Expectation Failed
138
+ 418 I'm a teapot
139
+ 421 Misdirected Request
140
+ 422 Unprocessable Entity
141
+ 423 Locked
142
+ 424 Failed Dependency
143
+ 425 Too Early
144
+ 426 Upgrade Required
145
+ 428 Precondition Required
146
+ 429 Too Many Requests
147
+ 431 Request Header Fields Too Large
148
+ 451 Unavailable For Legal Reasons
149
+
150
+
151
+ 5XX server errors
152
+
153
+ 500 Internal Server Error
154
+ 501 Not Implemented
155
+ 502 Bad Gateway
156
+ 503 Service Unavailable
157
+ 504 Gateway Timeout
158
+ 505 HTTP Version Not Supported
159
+ 506 Variant Also Negotiates
160
+ 507 Insufficient Storage
161
+ 508 Loop Detected
162
+ 510 Not Extended
163
+ 511 Network Authentication Required
164
+
165
+
166
+ Unofficial codes
167
+
168
+ 103 Checkpoint
169
+ 218 This is fine (Apache Web Server)
170
+ 419 Page Expired (Laravel Framework)
171
+ 420 Enhance Your Calm (Twitter)
172
+ 430 Request Header Fields Too Large (Shopify)
173
+ 450 Blocked by Windows Parental Controls (Microsoft)
174
+ 498 Invalid Token (Esri)
175
+ 499 Token Required (Esri)
176
+ 509 Bandwidth Limit Exceeded (Apache Web Server/cPanel)
177
+ 526 Invalid SSL Certificate
178
+ 529 Site is overloaded
179
+ 530 Site is frozen
180
+ 598 (Informal convention) Network read timeout error
181
+
182
+ 440 Login Time-out
183
+ 449 Retry With
184
+ 451 Redirect
185
+
186
+ 444 No Response
187
+ 494 Request header too large
188
+ 495 SSL Certificate Error
189
+ 496 SSL Certificate Required
190
+ 497 HTTP Request Sent to HTTPS Port
191
+ 499 Client Closed Request
192
+
193
+ 520 Web Server Returned an Unknown Error
194
+ 521 Web Server Is Down
195
+ 522 Connection Timed Out
196
+ 523 Origin Is Unreachable
197
+ 524 A Timeout Occurred
198
+ 525 SSL Handshake Failed
199
+ 526 Invalid SSL Certificate
200
+ 527 Railgun Error
201
+
202
+ 530
203
+
204
+ 460
205
+ 463
206
+
207
+ */
@@ -0,0 +1,26 @@
1
+
2
+ export interface GeoIpLocation {
3
+ /** [ <low bound of IP block>, <high bound of IP block> ] */
4
+ range: [number, number];
5
+ /** 2 letter ISO-3166-1 country code https://www.iban.com/country-codes */
6
+ country: string;
7
+ /**
8
+ * Up to 3 alphanumeric variable length characters as ISO 3166-2 code
9
+ * For US states this is the 2 letter state
10
+ * For the United Kingdom this could be ENG as a country like “England
11
+ * FIPS 10-4 subcountry code
12
+ */
13
+ region: string;
14
+ /** 1 if the country is a member state of the European Union, 0 otherwise. */
15
+ eu: '1' | '0';
16
+ /** "Country/Zone" Timezone from IANA Time Zone Database */
17
+ timezone: string;
18
+ /** This is the full city name */
19
+ city: string;
20
+ /** The latitude and longitude of the city */
21
+ ll: [number, number];
22
+ /** Metro code */
23
+ metro: number;
24
+ /** The approximate accuracy radius (km), around the latitude and longitude */
25
+ area: number;
26
+ }
@@ -0,0 +1,18 @@
1
+
2
+ export class DynamoUsageAction {
3
+ action?: string;
4
+ time?: Date;
5
+
6
+ constructor(
7
+ set?: {
8
+ action?: string,
9
+ time?: Date,
10
+ }
11
+ ) {
12
+ if (set) {
13
+ this.action = set.action;
14
+ this.time = set.time;
15
+ }
16
+ }
17
+ }
18
+
@@ -0,0 +1,26 @@
1
+
2
+ import { DynamoUsageAction } from './usage-action';
3
+
4
+ export class DynamoUsageData {
5
+ page?: string;
6
+ opened?: Date;
7
+ timeSpentOnPage?: number;
8
+ actions?: DynamoUsageAction[] = [];
9
+
10
+ constructor(
11
+ set?: {
12
+ page?: string,
13
+ opened?: Date;
14
+ timeSpentOnPage?: number,
15
+ actions?: DynamoUsageAction[],
16
+ }
17
+ ) {
18
+ if (set) {
19
+ this.page = set.page;
20
+ this.opened = set.opened;
21
+ this.timeSpentOnPage = set.timeSpentOnPage;
22
+ this.actions = set.actions ? set.actions : [];
23
+ }
24
+ }
25
+ }
26
+
@@ -0,0 +1,37 @@
1
+
2
+ import { DynamoBEDataPropertyParams } from '../control-models/dynamobe-data-property-params';
3
+ import { Metadata } from './metadata';
4
+
5
+ export class CustomData extends Metadata {
6
+ data?: string;
7
+
8
+ constructor(
9
+ set?: {
10
+ _id?: string,
11
+
12
+ data?: string,
13
+
14
+ __v?: number,
15
+ __created?: Date,
16
+ __createdBy?: string,
17
+ __lastModified?: Date,
18
+ __lastModifiedBy?: string,
19
+ }
20
+ ) {
21
+ super({
22
+ _id: set._id,
23
+ __v: set.__v,
24
+ __created: set.__created,
25
+ __createdBy: set.__createdBy,
26
+ __lastModified: set.__lastModified,
27
+ __lastModifiedBy: set.__lastModifiedBy,
28
+ })
29
+ if (set) {
30
+ this.data = set.data;
31
+ }
32
+ }
33
+ }
34
+
35
+ export const customDataModelParams: DynamoBEDataPropertyParams[] = [
36
+ { key: 'data', type: 'string', required: true },
37
+ ];
@@ -0,0 +1,28 @@
1
+
2
+
3
+ export class Metadata {
4
+ _id?: string;
5
+ __created?: Date;
6
+ __createdBy?: string;
7
+ __lastModified?: Date;
8
+ __lastModifiedBy?: string;
9
+ __v?: number;
10
+
11
+ constructor(metadata?: {
12
+ _id?: string,
13
+ __created?: Date,
14
+ __createdBy?: string,
15
+ __lastModified?: Date,
16
+ __lastModifiedBy?: string,
17
+ __v?: number;
18
+ } | Metadata){
19
+ if (metadata) {
20
+ this._id = metadata._id;
21
+ this.__created = metadata.__created;
22
+ this.__createdBy = metadata.__createdBy;
23
+ this.__lastModified = metadata.__lastModified;
24
+ this.__lastModifiedBy = metadata.__lastModifiedBy;
25
+ this.__v = metadata.__v;
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,82 @@
1
+
2
+ import { DynamoBEDataPropertyParams } from '../control-models/dynamobe-data-property-params';
3
+ import { GeoIpLocation } from '../control-models/geo-ip-location';
4
+ import { Metadata } from './metadata';
5
+ import { DynamoUsageData } from '../control-models/usage-data';
6
+
7
+ export class DynamoUsageSession extends Metadata {
8
+ date?: string;
9
+ sessionStart?: Date;
10
+ sessionEnd?: Date;
11
+ address?: string;
12
+ issuer?: string;
13
+ locationData?: GeoIpLocation;
14
+
15
+ usageData?: DynamoUsageData[];
16
+ totalSessionTime?: number;
17
+ loggedInAs?: string;
18
+
19
+ constructor(
20
+ set?: {
21
+ _id?: string,
22
+
23
+ date?: string;
24
+ sessionStart?: Date,
25
+ sessionEnd?: Date,
26
+ address?: string,
27
+ issuer?: string,
28
+ locationData?: GeoIpLocation,
29
+
30
+ usageData?: DynamoUsageData[],
31
+ totalSessionTime?: number,
32
+ loggedInAs?: string,
33
+
34
+ __created?: Date,
35
+ __createdBy?: string,
36
+ __lastModified?: Date,
37
+ __lastModifiedBy?: string,
38
+ __v?: number
39
+ }
40
+ ) {
41
+ super({
42
+ _id: set?._id,
43
+ __created: set?.__created,
44
+ __createdBy: set?.__createdBy,
45
+ __lastModified: set?.__lastModified,
46
+ __lastModifiedBy: set?.__lastModifiedBy,
47
+ __v: set?.__v,
48
+ });
49
+ if (set) {
50
+ if (set.date) {
51
+ this.date = set.date;
52
+ } else if (set.sessionStart) {
53
+ this.date = set.sessionStart.toISOString().substring(0, 10);
54
+ }
55
+ this.sessionStart = set.sessionStart;
56
+ this.sessionEnd = set.sessionEnd;
57
+ this.address = set.address;
58
+ this.issuer = set.issuer;
59
+ this.locationData = set.locationData;
60
+
61
+ this.usageData = set.usageData ? set.usageData : [];
62
+ this.totalSessionTime = set.totalSessionTime;
63
+ this.loggedInAs = set.loggedInAs;
64
+ }
65
+ }
66
+ }
67
+
68
+ export const usageSessionModelParams: DynamoBEDataPropertyParams[] = [
69
+ { key: 'date', type: 'string',
70
+ required: true, index: true
71
+ },
72
+ { key: 'sessionStart', type: 'Date',
73
+ required: true, index: true
74
+ },
75
+ { key: 'sessionEnd', type: 'Date' },
76
+ { key: 'address', type: 'string' },
77
+ { key: 'issuer', type: 'string' },
78
+ { key: 'locationData', type: 'IpApiLocation' },
79
+ { key: 'usageData', type: 'UsageData[]' },
80
+ { key: 'totalSessionTime', type: 'number' },
81
+ { key: 'loggedInAs', type: 'string' },
82
+ ];
@@ -0,0 +1,21 @@
1
+
2
+
3
+
4
+ import { CustomData, customDataModelParams } from '../../_models/fullstack-models/data-models/custom-data';
5
+ import { DynamoBEDataService } from '../../_services/dynamobe-data.service';
6
+ import { DBE_Global_S } from '../../_services/dynamobe-global.service';
7
+
8
+ export class CustomDataService extends DynamoBEDataService<CustomData> {
9
+
10
+ constructor(
11
+ customData?: CustomData,
12
+ issuer?: string,
13
+ ) {
14
+ super(
15
+ DBE_Global_S.getDBServiceCollection().customDataDBService,
16
+ new CustomData(customData),
17
+ customDataModelParams,
18
+ issuer
19
+ );
20
+ }
21
+ }
@@ -0,0 +1,136 @@
1
+
2
+ import { Request, Response } from 'express';
3
+ import { HttpCallType } from '../../_enum/http/http-call-type.enum';
4
+ import { DynamoBEEndpointParams } from '../../_models/dynamobe-endpoint-control';
5
+ import { DynamoBEController } from '../../_services/dynamobe-controller.service';
6
+ import { CustomDataService } from './custom-data.service';
7
+
8
+ export class TestController extends DynamoBEController {
9
+
10
+ static getInstance(): TestController {
11
+ return TestController.getSingletonInstance();
12
+ }
13
+
14
+ setupEndpoints(): void {
15
+ this.endpoints = [
16
+ // TESTS
17
+ new DynamoBEEndpointParams({
18
+ name: 'testGet',
19
+ type: HttpCallType.get,
20
+ endpoint: '/test-get',
21
+ tasks: [
22
+ async (req: Request, res: Response) => {
23
+ res.send({
24
+ url: req.url,
25
+ result: 'test-get call was successful!',
26
+ request: req.body
27
+ });
28
+ }
29
+ ]
30
+ }),
31
+
32
+ new DynamoBEEndpointParams({
33
+ name: 'testPost',
34
+ type: HttpCallType.post,
35
+ endpoint: '/test-post',
36
+ tasks: [
37
+ async (req: Request, res: Response) => {
38
+ res.send({
39
+ url: req.url,
40
+ result: 'test-post call was successful!',
41
+ request: req.body
42
+ });
43
+ }
44
+ ]
45
+ }),
46
+
47
+ new DynamoBEEndpointParams({
48
+ name: 'testPut',
49
+ type: HttpCallType.put,
50
+ endpoint: '/test-put',
51
+ tasks: [
52
+ async (req: Request, res: Response) => {
53
+ res.send({
54
+ url: req.url,
55
+ result: 'test-put call was successful!',
56
+ request: req.body
57
+ });
58
+ }
59
+ ]
60
+ }),
61
+
62
+ new DynamoBEEndpointParams({
63
+ name: 'testPatch',
64
+ type: HttpCallType.patch,
65
+ endpoint: '/test-patch',
66
+ tasks: [
67
+ async (req: Request, res: Response) => {
68
+ res.send({
69
+ url: req.url,
70
+ result: 'test-patch call was successful!',
71
+ request: req.body
72
+ });
73
+ }
74
+ ]
75
+ }),
76
+
77
+ new DynamoBEEndpointParams({
78
+ name: 'testDelete',
79
+ type: HttpCallType.delete,
80
+ endpoint: '/test-delete',
81
+ tasks: [
82
+ async (req: Request, res: Response) => {
83
+ res.send({
84
+ url: req.url,
85
+ result: 'test-delete call was successful!',
86
+ request: req.body
87
+ });
88
+ }
89
+ ]
90
+ }),
91
+
92
+ // CUSTOM DATA
93
+ new DynamoBEEndpointParams({
94
+ name: 'getCustomData',
95
+ type: HttpCallType.get,
96
+ endpoint: '/custom/get/:customId',
97
+ tasks: [
98
+ async (req: Request, res: Response) => {
99
+ const customDataService = new CustomDataService({ _id: req.params.customId });
100
+
101
+ await customDataService.getDataById();
102
+
103
+ res.send({
104
+ url: req.url,
105
+ result: 'get custom call was successful!',
106
+ response: customDataService.data,
107
+ request: `.../custom/get/${req.params.customId}`
108
+ });
109
+ }
110
+ ]
111
+ }),
112
+
113
+ new DynamoBEEndpointParams({
114
+ name: 'modifyCustomData',
115
+ type: HttpCallType.post,
116
+ endpoint: '/custom/post',
117
+ tasks: [
118
+ async (req: Request, res: Response, issuer: string) => {
119
+ const customDataService = new CustomDataService(req.body, issuer);
120
+
121
+ await customDataService.saveData();
122
+
123
+ res.send({
124
+ url: req.url,
125
+ result: 'post custom call was successful!',
126
+ response: customDataService.data,
127
+ warning: 'keep in mind that this is a playground DB, and it will be cleared out from time to time',
128
+ request: req.body
129
+ });
130
+ }
131
+ ]
132
+ }),
133
+ ];
134
+ }
135
+ }
136
+
@@ -0,0 +1,114 @@
1
+
2
+ import { Request, Response } from 'express';
3
+ import { HttpCallType } from '../../_enum/http/http-call-type.enum';
4
+ import { DynamoBEEndpointParams } from '../../_models/dynamobe-endpoint-control';
5
+ import { DynamoUsageSession } from '../../_models/fullstack-models/data-models/usage-session';
6
+ import { DynamoBEAuthService } from '../../_services/dynamobe-auth.service';
7
+ import { DynamoBEController } from '../../_services/dynamobe-controller.service';
8
+ import { DBE_Global_S } from '../../_services/dynamobe-global.service';
9
+ import { UsageService } from './usage.service';
10
+
11
+ export class UsageController extends DynamoBEController {
12
+
13
+ static getInstance(): UsageController {
14
+ return UsageController.getSingletonInstance();
15
+ }
16
+
17
+ // SERVICES
18
+ private authService: DynamoBEAuthService;
19
+
20
+ setupEndpoints(): void {
21
+ this.authService = DBE_Global_S.getAuthService();
22
+
23
+ this.endpoints = [
24
+ new DynamoBEEndpointParams({
25
+ name: 'newSession',
26
+ type: HttpCallType.get,
27
+ endpoint: '/new-session',
28
+ tasks: [
29
+ async (req: Request, res: Response, issuer: string) => {
30
+ const authService = DBE_Global_S.getAuthService();
31
+ const username = authService.getUsernameFromRequest(req);
32
+ const usageService = new UsageService({
33
+ usageSession: new DynamoUsageSession({
34
+ sessionStart: new Date(),
35
+ issuer: username,
36
+ }),
37
+ issuer
38
+ });
39
+
40
+ await usageService.getLocationDataFromRequest(req);
41
+ await usageService.saveData();
42
+
43
+ res.send(
44
+ usageService.data
45
+ );
46
+ }
47
+ ]
48
+ }),
49
+
50
+ new DynamoBEEndpointParams({
51
+ name: 'updateUsageData',
52
+ type: HttpCallType.post,
53
+ endpoint: '/update/:sessionId',
54
+ logRequestsContent: false,
55
+ tasks: [
56
+ async (req: Request, res: Response, issuer: string) => {
57
+ const usageService = new UsageService({
58
+ usageSession: { _id: req.params.sessionId },
59
+ usageData: req.body,
60
+ issuer
61
+ });
62
+
63
+ await usageService.updateUsageData(req);
64
+
65
+ res.send(
66
+ usageService.data
67
+ );
68
+ }
69
+ ]
70
+ }),
71
+
72
+ new DynamoBEEndpointParams({
73
+ name: 'closeSession',
74
+ type: HttpCallType.get,
75
+ endpoint: '/close-session/:sessionId',
76
+ preProcessess: [ this.authService.authTokenPermAccUsageData ],
77
+ tasks: [
78
+ async (req: Request, res: Response, issuer: string) => {
79
+ const usageService = new UsageService({
80
+ usageSession: { _id: req.params.sessionId },
81
+ issuer
82
+ });
83
+
84
+ await usageService.closeSession(req);
85
+
86
+ res.send(
87
+ usageService.data
88
+ );
89
+ }
90
+ ]
91
+ }),
92
+
93
+ new DynamoBEEndpointParams({
94
+ name: 'getAllUsageData',
95
+ type: HttpCallType.get,
96
+ endpoint: '/get/all',
97
+ preProcessess: [ this.authService.authTokenPermAccUsageData ],
98
+ tasks: [
99
+ async (req: Request, res: Response) => {
100
+ const usageService = new UsageService();
101
+
102
+ await usageService.getLastWeekUsage();
103
+
104
+ res.send(
105
+ usageService.simplifiedDailyUsage
106
+ );
107
+ }
108
+ ]
109
+ }),
110
+
111
+ ];
112
+ }
113
+ }
114
+