@thzero/library_server 0.18.2 → 0.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/boot/plugins/api.js
CHANGED
|
@@ -14,6 +14,9 @@ class ApiBootPlugin extends BootPlugin {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async _initRoutesPre() {
|
|
17
|
+
const routeUsageMetrics = this._initRoutesUsageMetrics();
|
|
18
|
+
if (routeUsageMetrics)
|
|
19
|
+
this._initRoute(routeUsageMetrics);
|
|
17
20
|
this._initRoute(this._initRoutesVersion());
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -33,6 +36,10 @@ class ApiBootPlugin extends BootPlugin {
|
|
|
33
36
|
throw new NotImplementedError();
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
_initRoutesUsageMetrics() {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
_initRoutesVersion() {
|
|
37
44
|
throw new NotImplementedError();
|
|
38
45
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.4",
|
|
5
5
|
"version_major": 0,
|
|
6
6
|
"version_minor": 18,
|
|
7
|
-
"version_patch":
|
|
8
|
-
"version_date": "
|
|
7
|
+
"version_patch": 4,
|
|
8
|
+
"version_date": "04/06/2024",
|
|
9
9
|
"description": "An opinionated library of common functionality to bootstrap an API using either Fastify or Koa as the web server.",
|
|
10
10
|
"author": "thZero",
|
|
11
11
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@godaddy/terminus": "^4.12.1",
|
|
29
|
-
"async-mutex": "^0.
|
|
29
|
+
"async-mutex": "^0.5.0",
|
|
30
30
|
"config": "^3.3.11",
|
|
31
31
|
"default-gateway": "^7.2.2",
|
|
32
32
|
"easy-rbac": "^3.2.0",
|
|
@@ -6,6 +6,11 @@ class DevNullUsageMetricsRepository extends Repository {
|
|
|
6
6
|
// Do nothing here.
|
|
7
7
|
return this._success(correlationId);
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
async tag(correlationId, userId, tag) {
|
|
11
|
+
// Do nothing here.
|
|
12
|
+
return this._success(correlationId);
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
export default DevNullUsageMetricsRepository;
|
package/service/usageMetrics.js
CHANGED
|
@@ -49,6 +49,23 @@ class UsageMetricsService extends Service {
|
|
|
49
49
|
this._ignore.push(url);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
async tag(correlationId, user, tag) {
|
|
53
|
+
this._enforceNotNull('UsageMetricsService', 'tag', 'user', user, correlationId);
|
|
54
|
+
this._enforceNotNull('UsageMetricsService', 'tag', 'tag', tag, correlationId);
|
|
55
|
+
|
|
56
|
+
if (user) {
|
|
57
|
+
const validationResponsUser = this._validateUser(correlationId, user);
|
|
58
|
+
if (this._hasFailed(validationResponsUser))
|
|
59
|
+
return validationResponsUser;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const validationResponse = this._serviceValidation.check(correlationId, this._serviceValidation.usageMetricsMeasurementTag, tag);
|
|
63
|
+
if (this._hasFailed(validationResponse))
|
|
64
|
+
return validationResponse;
|
|
65
|
+
|
|
66
|
+
return await this._repositoryUsageMetrics.tag(correlationId, user ? user.id : null, tag);
|
|
67
|
+
}
|
|
68
|
+
|
|
52
69
|
get _repositoryUsageMetrics() {
|
|
53
70
|
return this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_USAGE_METRIC)
|
|
54
71
|
}
|