@thzero/library_server 0.17.2 → 0.17.3

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 (53) hide show
  1. package/README.md +93 -93
  2. package/boot/index.js +431 -431
  3. package/boot/plugins/admin/index.js +6 -6
  4. package/boot/plugins/admin/news.js +33 -33
  5. package/boot/plugins/admin/users.js +33 -33
  6. package/boot/plugins/api.js +57 -57
  7. package/boot/plugins/apiFront.js +31 -31
  8. package/boot/plugins/index.js +70 -70
  9. package/boot/plugins/news.js +44 -44
  10. package/boot/plugins/users.js +46 -46
  11. package/boot/plugins/usersExtended.js +32 -32
  12. package/constants.js +45 -45
  13. package/data/baseNews.js +42 -42
  14. package/data/baseSettingsUser.js +9 -9
  15. package/data/baseUser.js +28 -28
  16. package/data/index.js +24 -24
  17. package/data/named.js +20 -20
  18. package/errors/tokenExpired.js +7 -7
  19. package/license.md +8 -8
  20. package/openSource.js +66 -66
  21. package/package.json +36 -36
  22. package/repository/index.js +174 -174
  23. package/repository/usageMetrics/devnull.js +11 -11
  24. package/routes/index.js +76 -76
  25. package/service/admin/baseNews.js +45 -45
  26. package/service/admin/index.js +130 -130
  27. package/service/admin/news.js +6 -6
  28. package/service/admin/users.js +107 -107
  29. package/service/baseSecurity.js +44 -44
  30. package/service/baseUser.js +122 -122
  31. package/service/communication.js +6 -6
  32. package/service/config.js +32 -32
  33. package/service/crypto.js +16 -16
  34. package/service/discovery/index.js +6 -6
  35. package/service/discovery/resources/index.js +101 -101
  36. package/service/external.js +19 -19
  37. package/service/externalRest.js +19 -19
  38. package/service/index.js +20 -20
  39. package/service/monitoring.js +12 -12
  40. package/service/news/base.js +49 -49
  41. package/service/news/index.js +6 -6
  42. package/service/news/validation/index.js +6 -6
  43. package/service/plans.js +27 -27
  44. package/service/restCommunication.js +21 -21
  45. package/service/usageMetrics.js +57 -57
  46. package/service/utility.js +177 -177
  47. package/service/version.js +32 -32
  48. package/utility/injector.js +59 -59
  49. package/utility/internalIp/index.js +48 -48
  50. package/utility/list/doubleLinked.js +88 -88
  51. package/utility/list/priorityQueue.js +109 -109
  52. package/utility/list/queue.js +72 -72
  53. package/utility/os.js +20 -20
package/service/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import Service from '@thzero/library_common_service/service/index.js';
2
-
3
- class ServerService extends Service {
4
- constructor() {
5
- super();
6
- }
7
-
8
- _validateUser(correlationId, user) {
9
- if (!user)
10
- return this._error('Service', '_validateUser', 'Invalid user', null, null, null, correlationId);
11
-
12
- if (String.isNullOrEmpty(user.id))
13
- return this._error('Service', '_validateUser', 'Invalid user.id', null, null, null, correlationId);
14
-
15
- this._logger.debug('Service', '_validateUser', 'userId', user.id, correlationId);
16
- return this._success(correlationId);
17
- }
18
- }
19
-
20
- export default ServerService;
1
+ import Service from '@thzero/library_common_service/service/index.js';
2
+
3
+ class ServerService extends Service {
4
+ constructor() {
5
+ super();
6
+ }
7
+
8
+ _validateUser(correlationId, user) {
9
+ if (!user)
10
+ return this._error('Service', '_validateUser', 'Invalid user', null, null, null, correlationId);
11
+
12
+ if (String.isNullOrEmpty(user.id))
13
+ return this._error('Service', '_validateUser', 'Invalid user.id', null, null, null, correlationId);
14
+
15
+ this._logger.debug('Service', '_validateUser', 'userId', user.id, correlationId);
16
+ return this._success(correlationId);
17
+ }
18
+ }
19
+
20
+ export default ServerService;
@@ -1,13 +1,13 @@
1
- import BaseMonitoringService from '@thzero/library_common_service/service/monitoring.js';
2
-
3
- class NullMonitoringService extends BaseMonitoringService {
4
- constructor() {
5
- super();
6
- }
7
-
8
- async init(injector) {
9
- await super.init(injector);
10
- }
11
- }
12
-
1
+ import BaseMonitoringService from '@thzero/library_common_service/service/monitoring.js';
2
+
3
+ class NullMonitoringService extends BaseMonitoringService {
4
+ constructor() {
5
+ super();
6
+ }
7
+
8
+ async init(injector) {
9
+ await super.init(injector);
10
+ }
11
+ }
12
+
13
13
  export default NullMonitoringService;
@@ -1,49 +1,49 @@
1
- import LibraryServerConstants from '../../constants.js';
2
-
3
- import Service from '../../service/index.js';
4
-
5
- class BaseNewsService extends Service {
6
- constructor() {
7
- super();
8
-
9
- this._repositoryNewsI = null;
10
-
11
- this._serviceValidationNews = null;
12
- }
13
-
14
- async init(injector) {
15
- await super.init(injector);
16
-
17
- this._repositoryNewsI = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_NEWS);
18
-
19
- this._serviceValidationNews = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_VALIDATION_NEWS);
20
- }
21
-
22
- async latest(correlationId, user, timestamp) {
23
- this._logger.debug('BaseNewsService', 'latest', 'date', timestamp, correlationId);
24
- if (!timestamp)
25
- return this._error('BaseNewsService', 'latest', 'Invalid timestamp.', null, null, null, correlationId);
26
-
27
- const validationCheckNewsTiemstampResponse = this._serviceValidation.check(correlationId, this._serviceValidationNews.newsTimestampSchema, timestamp, null, 'news');
28
- if (!validationCheckNewsTiemstampResponse.success)
29
- return validationCheckNewsTiemstampResponse;
30
-
31
- const respositoryResponse = await this._repositoryNews.latest(correlationId, timestamp);
32
- if (this._hasFailed(respositoryResponse))
33
- return respositoryResponse;
34
-
35
- let data = respositoryResponse.results.data;
36
- if (data)
37
- data = data.filter(l => (l.requiresAuth && user) || !l.requiresAuth);
38
- respositoryResponse.results.data = data;
39
- respositoryResponse.results.count = data.length;
40
-
41
- return respositoryResponse;
42
- }
43
-
44
- get _repositoryNews() {
45
- return this._repositoryNewsI;
46
- }
47
- }
48
-
49
- export default BaseNewsService;
1
+ import LibraryServerConstants from '../../constants.js';
2
+
3
+ import Service from '../../service/index.js';
4
+
5
+ class BaseNewsService extends Service {
6
+ constructor() {
7
+ super();
8
+
9
+ this._repositoryNewsI = null;
10
+
11
+ this._serviceValidationNews = null;
12
+ }
13
+
14
+ async init(injector) {
15
+ await super.init(injector);
16
+
17
+ this._repositoryNewsI = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_NEWS);
18
+
19
+ this._serviceValidationNews = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_VALIDATION_NEWS);
20
+ }
21
+
22
+ async latest(correlationId, user, timestamp) {
23
+ this._logger.debug('BaseNewsService', 'latest', 'date', timestamp, correlationId);
24
+ if (!timestamp)
25
+ return this._error('BaseNewsService', 'latest', 'Invalid timestamp.', null, null, null, correlationId);
26
+
27
+ const validationCheckNewsTiemstampResponse = this._serviceValidation.check(correlationId, this._serviceValidationNews.newsTimestampSchema, timestamp, null, 'news');
28
+ if (!validationCheckNewsTiemstampResponse.success)
29
+ return validationCheckNewsTiemstampResponse;
30
+
31
+ const respositoryResponse = await this._repositoryNews.latest(correlationId, timestamp);
32
+ if (this._hasFailed(respositoryResponse))
33
+ return respositoryResponse;
34
+
35
+ let data = respositoryResponse.results.data;
36
+ if (data)
37
+ data = data.filter(l => (l.requiresAuth && user) || !l.requiresAuth);
38
+ respositoryResponse.results.data = data;
39
+ respositoryResponse.results.count = data.length;
40
+
41
+ return respositoryResponse;
42
+ }
43
+
44
+ get _repositoryNews() {
45
+ return this._repositoryNewsI;
46
+ }
47
+ }
48
+
49
+ export default BaseNewsService;
@@ -1,6 +1,6 @@
1
- import BaseNewsService from './base.js';
2
-
3
- class NewsService extends BaseNewsService {
4
- }
5
-
6
- export default NewsService;
1
+ import BaseNewsService from './base.js';
2
+
3
+ class NewsService extends BaseNewsService {
4
+ }
5
+
6
+ export default NewsService;
@@ -1,6 +1,6 @@
1
- import BaseNewsJoiBaseValidationService from './joi.js';
2
-
3
- class NewsValidationService extends BaseNewsJoiBaseValidationService {
4
- }
5
-
6
- export default NewsValidationService;
1
+ import BaseNewsJoiBaseValidationService from './joi.js';
2
+
3
+ class NewsValidationService extends BaseNewsJoiBaseValidationService {
4
+ }
5
+
6
+ export default NewsValidationService;
package/service/plans.js CHANGED
@@ -1,28 +1,28 @@
1
- import LibraryServerConstants from '../constants.js';
2
-
3
- import Service from './index.js';
4
-
5
- class PlansService extends Service {
6
- constructor() {
7
- super();
8
-
9
- this._repositoryPlansI = null;
10
- }
11
-
12
- async init(injector) {
13
- await super.init(injector);
14
-
15
- this._repositoryPlansI = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_PLANS);
16
- }
17
-
18
- async listing(correlationId) {
19
- const respositoryResponse = await this._repositoryPlans.listing(correlationId);
20
- return respositoryResponse;
21
- }
22
-
23
- get _repositoryPlans() {
24
- return this._repositoryPlansI;
25
- }
26
- }
27
-
1
+ import LibraryServerConstants from '../constants.js';
2
+
3
+ import Service from './index.js';
4
+
5
+ class PlansService extends Service {
6
+ constructor() {
7
+ super();
8
+
9
+ this._repositoryPlansI = null;
10
+ }
11
+
12
+ async init(injector) {
13
+ await super.init(injector);
14
+
15
+ this._repositoryPlansI = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_PLANS);
16
+ }
17
+
18
+ async listing(correlationId) {
19
+ const respositoryResponse = await this._repositoryPlans.listing(correlationId);
20
+ return respositoryResponse;
21
+ }
22
+
23
+ get _repositoryPlans() {
24
+ return this._repositoryPlansI;
25
+ }
26
+ }
27
+
28
28
  export default PlansService;
@@ -1,21 +1,21 @@
1
- import CommunicationService from './communication.js';
2
-
3
- class RestCommunicationService extends CommunicationService {
4
- // eslint-disable-next-line
5
- async get(key, url, options) {
6
- }
7
-
8
- // eslint-disable-next-line
9
- async getAuth(key, url, auth, options) {
10
- }
11
-
12
- // eslint-disable-next-line
13
- async post(key, url, body, options) {
14
- }
15
-
16
- // eslint-disable-next-line
17
- async postAuth(key, url, body, auth, options) {
18
- }
19
- }
20
-
21
- export default RestCommunicationService;
1
+ import CommunicationService from './communication.js';
2
+
3
+ class RestCommunicationService extends CommunicationService {
4
+ // eslint-disable-next-line
5
+ async get(key, url, options) {
6
+ }
7
+
8
+ // eslint-disable-next-line
9
+ async getAuth(key, url, auth, options) {
10
+ }
11
+
12
+ // eslint-disable-next-line
13
+ async post(key, url, body, options) {
14
+ }
15
+
16
+ // eslint-disable-next-line
17
+ async postAuth(key, url, body, auth, options) {
18
+ }
19
+ }
20
+
21
+ export default RestCommunicationService;
@@ -1,57 +1,57 @@
1
- import LibraryServerConstants from '../constants.js';
2
-
3
- import LibraryCommonUtility from '@thzero/library_common/utility/index.js';
4
-
5
- import Service from './index.js';
6
-
7
- class UsageMetricsService extends Service {
8
- constructor() {
9
- super();
10
-
11
- this._ignore = [];
12
-
13
- this._repositoryUsageMetricsI = null;
14
- }
15
-
16
- async init(injector) {
17
- await super.init(injector);
18
-
19
- this._repositoryUsageMetricsI = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_USAGE_METRIC);
20
- }
21
-
22
- async register(usageMetrics, err) {
23
- try {
24
- if (!usageMetrics)
25
- return;
26
-
27
- const url = usageMetrics.url;
28
- if (!String.isNullOrEmpty(url)) {
29
- for (const ignore of this._ignore) {
30
- if (url === ignore)
31
- return;
32
- }
33
- }
34
-
35
- usageMetrics.date = new Date(new Date(LibraryCommonUtility.getTimestamp()).toISOString());
36
-
37
- await this._repositoryUsageMetrics.register(usageMetrics);
38
- return this._success(usageMetrics.correlationId);
39
- }
40
- catch (err) {
41
- this._logger.exception('UsageMetricsService', 'register', err);
42
- }
43
- }
44
-
45
- registerIgnore(url) {
46
- if (this._ignore[url])
47
- return;
48
-
49
- this._ignore.push(url);
50
- }
51
-
52
- get _repositoryUsageMetrics() {
53
- return this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_USAGE_METRIC)
54
- }
55
- }
56
-
57
- export default UsageMetricsService;
1
+ import LibraryServerConstants from '../constants.js';
2
+
3
+ import LibraryCommonUtility from '@thzero/library_common/utility/index.js';
4
+
5
+ import Service from './index.js';
6
+
7
+ class UsageMetricsService extends Service {
8
+ constructor() {
9
+ super();
10
+
11
+ this._ignore = [];
12
+
13
+ this._repositoryUsageMetricsI = null;
14
+ }
15
+
16
+ async init(injector) {
17
+ await super.init(injector);
18
+
19
+ this._repositoryUsageMetricsI = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_USAGE_METRIC);
20
+ }
21
+
22
+ async register(usageMetrics, err) {
23
+ try {
24
+ if (!usageMetrics)
25
+ return;
26
+
27
+ const url = usageMetrics.url;
28
+ if (!String.isNullOrEmpty(url)) {
29
+ for (const ignore of this._ignore) {
30
+ if (url === ignore)
31
+ return;
32
+ }
33
+ }
34
+
35
+ usageMetrics.date = new Date(new Date(LibraryCommonUtility.getTimestamp()).toISOString());
36
+
37
+ await this._repositoryUsageMetrics.register(usageMetrics);
38
+ return this._success(usageMetrics.correlationId);
39
+ }
40
+ catch (err) {
41
+ this._logger.exception('UsageMetricsService', 'register', err);
42
+ }
43
+ }
44
+
45
+ registerIgnore(url) {
46
+ if (this._ignore[url])
47
+ return;
48
+
49
+ this._ignore.push(url);
50
+ }
51
+
52
+ get _repositoryUsageMetrics() {
53
+ return this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_USAGE_METRIC)
54
+ }
55
+ }
56
+
57
+ export default UsageMetricsService;