@thzero/library_server_fastify 0.17.4 → 0.17.6
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/package.json +4 -4
- package/routes/utility.js +13 -3
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_server_fastify",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.6",
|
|
5
5
|
"version_major": 0,
|
|
6
6
|
"version_minor": 17,
|
|
7
|
-
"version_patch":
|
|
8
|
-
"version_date": "03/
|
|
7
|
+
"version_patch": 6,
|
|
8
|
+
"version_date": "03/18/2023",
|
|
9
9
|
"description": "An opinionated library of common functionality to bootstrap a Fastify based API application.",
|
|
10
10
|
"author": "thZero",
|
|
11
11
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@fastify/auth": "^4.2.0",
|
|
29
29
|
"@fastify/compress": "^6.2.0",
|
|
30
|
-
"@fastify/cors": "^8.2.
|
|
30
|
+
"@fastify/cors": "^8.2.1",
|
|
31
31
|
"@fastify/helmet": "^10.1.0",
|
|
32
32
|
"@fastify/routes": "^5.1.0",
|
|
33
33
|
"@fastify/static": "^6.9.0",
|
package/routes/utility.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import LibraryCommonServiceConstants from '@thzero/library_common_service/constants.js';
|
|
1
2
|
import LibraryServerConstants from '@thzero/library_server/constants.js';
|
|
2
3
|
|
|
3
4
|
import BaseRoute from './index.js';
|
|
@@ -6,13 +7,22 @@ class UtilityRoute extends BaseRoute {
|
|
|
6
7
|
constructor(prefix) {
|
|
7
8
|
super(prefix ? prefix : '/utility');
|
|
8
9
|
|
|
10
|
+
this._loggerRequiresAuth = false;
|
|
9
11
|
// this._serviceUtility = null;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
async init(injector, app, config) {
|
|
13
15
|
await super.init(injector, app, config);
|
|
16
|
+
|
|
17
|
+
const serviceConfig = injector.getService(LibraryCommonServiceConstants.InjectorKeys.SERVICE_CONFIG);
|
|
14
18
|
// this._serviceUtility = injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_UTILITY);
|
|
15
19
|
this._inject(app, injector, LibraryServerConstants.InjectorKeys.SERVICE_UTILITY, LibraryServerConstants.InjectorKeys.SERVICE_UTILITY);
|
|
20
|
+
|
|
21
|
+
const auth = serviceConfig.get('auth');
|
|
22
|
+
if (auth) {
|
|
23
|
+
const temp = auth.logger && auth.logger.external.required && auth.logger.external.required ? auth.logger.external.required : false;
|
|
24
|
+
this._loggerRequiresAuth = temp;
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
get id() {
|
|
@@ -29,10 +39,10 @@ class UtilityRoute extends BaseRoute {
|
|
|
29
39
|
}
|
|
30
40
|
);
|
|
31
41
|
|
|
32
|
-
router.post('/logger',
|
|
42
|
+
router.post(this._join('/logger'),
|
|
33
43
|
// authentication(false),
|
|
34
44
|
// // authorization('utility'),
|
|
35
|
-
{
|
|
45
|
+
this._loggerRequiresAuth ? {
|
|
36
46
|
preHandler: router.auth([
|
|
37
47
|
router.authenticationDefault,
|
|
38
48
|
// router.authorizationDefault
|
|
@@ -42,7 +52,7 @@ class UtilityRoute extends BaseRoute {
|
|
|
42
52
|
required: false,
|
|
43
53
|
roles: [ 'utility' ]
|
|
44
54
|
}),
|
|
45
|
-
},
|
|
55
|
+
} : {},
|
|
46
56
|
// eslint-disable-next-line
|
|
47
57
|
async (request, reply) => {
|
|
48
58
|
// const service = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_UTILITY);
|