@thzero/library_server_fastify 0.17.6 → 0.17.8
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/README.md +17 -17
- package/boot/index.js +367 -367
- package/boot/plugins/admin/news.js +11 -11
- package/boot/plugins/admin/users.js +11 -11
- package/boot/plugins/api.js +16 -16
- package/boot/plugins/apiFront.js +21 -21
- package/boot/plugins/news.js +11 -11
- package/boot/plugins/users.js +11 -11
- package/boot/plugins/usersExtended.js +6 -6
- package/license.md +8 -8
- package/middleware/authentication.js +94 -94
- package/middleware/authorization.js +112 -220
- package/openSource.js +80 -80
- package/package.json +41 -41
- package/plugins/apiKey.js +48 -48
- package/plugins/auth.js +124 -124
- package/plugins/responseTime.js +111 -111
- package/plugins/settings.js +12 -12
- package/plugins/usageMetrics.js +24 -24
- package/routes/admin/index.js +140 -140
- package/routes/admin/news.js +22 -22
- package/routes/admin/users.js +26 -26
- package/routes/baseNews.js +45 -45
- package/routes/baseUsers.js +153 -153
- package/routes/home.js +28 -28
- package/routes/index.js +41 -41
- package/routes/news.js +6 -6
- package/routes/plans.js +39 -39
- package/routes/users.js +6 -6
- package/routes/utility.js +80 -80
- package/routes/version.js +39 -39
package/routes/utility.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import LibraryCommonServiceConstants from '@thzero/library_common_service/constants.js';
|
|
2
|
-
import LibraryServerConstants from '@thzero/library_server/constants.js';
|
|
3
|
-
|
|
4
|
-
import BaseRoute from './index.js';
|
|
5
|
-
|
|
6
|
-
class UtilityRoute extends BaseRoute {
|
|
7
|
-
constructor(prefix) {
|
|
8
|
-
super(prefix ? prefix : '/utility');
|
|
9
|
-
|
|
10
|
-
this._loggerRequiresAuth = false;
|
|
11
|
-
// this._serviceUtility = null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async init(injector, app, config) {
|
|
15
|
-
await super.init(injector, app, config);
|
|
16
|
-
|
|
17
|
-
const serviceConfig = injector.getService(LibraryCommonServiceConstants.InjectorKeys.SERVICE_CONFIG);
|
|
18
|
-
// this._serviceUtility = injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_UTILITY);
|
|
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
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get id() {
|
|
29
|
-
return 'utility';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
_initializeRoutes(router) {
|
|
33
|
-
router.get(this._join('/initialize'),
|
|
34
|
-
// eslint-disable-next-line
|
|
35
|
-
async (request, reply) => {
|
|
36
|
-
const response = (await router[LibraryServerConstants.InjectorKeys.SERVICE_UTILITY].initialize(request.correlationId)).check(request);
|
|
37
|
-
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
38
|
-
return this._jsonResponse(reply, response);
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
router.post(this._join('/logger'),
|
|
43
|
-
// authentication(false),
|
|
44
|
-
// // authorization('utility'),
|
|
45
|
-
this._loggerRequiresAuth ? {
|
|
46
|
-
preHandler: router.auth([
|
|
47
|
-
router.authenticationDefault,
|
|
48
|
-
// router.authorizationDefault
|
|
49
|
-
],
|
|
50
|
-
{
|
|
51
|
-
relation: 'and',
|
|
52
|
-
required: false,
|
|
53
|
-
roles: [ 'utility' ]
|
|
54
|
-
}),
|
|
55
|
-
} : {},
|
|
56
|
-
// eslint-disable-next-line
|
|
57
|
-
async (request, reply) => {
|
|
58
|
-
// const service = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_UTILITY);
|
|
59
|
-
const response = (await router[LibraryServerConstants.InjectorKeys.SERVICE_UTILITY].logger(request.correlationId, request.body)).check(request);
|
|
60
|
-
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
61
|
-
return this._jsonResponse(reply, response);
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
router.get(this._join('/openSource'),
|
|
66
|
-
// eslint-disable-next-line
|
|
67
|
-
async (request, reply) => {
|
|
68
|
-
const response = (await router[LibraryServerConstants.InjectorKeys.SERVICE_UTILITY].openSource(request.correlationId)).check(request);
|
|
69
|
-
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
70
|
-
return this._jsonResponse(reply, response);
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
get _version() {
|
|
76
|
-
return 'v1';
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default UtilityRoute;
|
|
1
|
+
import LibraryCommonServiceConstants from '@thzero/library_common_service/constants.js';
|
|
2
|
+
import LibraryServerConstants from '@thzero/library_server/constants.js';
|
|
3
|
+
|
|
4
|
+
import BaseRoute from './index.js';
|
|
5
|
+
|
|
6
|
+
class UtilityRoute extends BaseRoute {
|
|
7
|
+
constructor(prefix) {
|
|
8
|
+
super(prefix ? prefix : '/utility');
|
|
9
|
+
|
|
10
|
+
this._loggerRequiresAuth = false;
|
|
11
|
+
// this._serviceUtility = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async init(injector, app, config) {
|
|
15
|
+
await super.init(injector, app, config);
|
|
16
|
+
|
|
17
|
+
const serviceConfig = injector.getService(LibraryCommonServiceConstants.InjectorKeys.SERVICE_CONFIG);
|
|
18
|
+
// this._serviceUtility = injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_UTILITY);
|
|
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
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get id() {
|
|
29
|
+
return 'utility';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_initializeRoutes(router) {
|
|
33
|
+
router.get(this._join('/initialize'),
|
|
34
|
+
// eslint-disable-next-line
|
|
35
|
+
async (request, reply) => {
|
|
36
|
+
const response = (await router[LibraryServerConstants.InjectorKeys.SERVICE_UTILITY].initialize(request.correlationId)).check(request);
|
|
37
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
38
|
+
return this._jsonResponse(reply, response);
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
router.post(this._join('/logger'),
|
|
43
|
+
// authentication(false),
|
|
44
|
+
// // authorization('utility'),
|
|
45
|
+
this._loggerRequiresAuth ? {
|
|
46
|
+
preHandler: router.auth([
|
|
47
|
+
router.authenticationDefault,
|
|
48
|
+
// router.authorizationDefault
|
|
49
|
+
],
|
|
50
|
+
{
|
|
51
|
+
relation: 'and',
|
|
52
|
+
required: false,
|
|
53
|
+
roles: [ 'utility' ]
|
|
54
|
+
}),
|
|
55
|
+
} : {},
|
|
56
|
+
// eslint-disable-next-line
|
|
57
|
+
async (request, reply) => {
|
|
58
|
+
// const service = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_UTILITY);
|
|
59
|
+
const response = (await router[LibraryServerConstants.InjectorKeys.SERVICE_UTILITY].logger(request.correlationId, request.body)).check(request);
|
|
60
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
61
|
+
return this._jsonResponse(reply, response);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
router.get(this._join('/openSource'),
|
|
66
|
+
// eslint-disable-next-line
|
|
67
|
+
async (request, reply) => {
|
|
68
|
+
const response = (await router[LibraryServerConstants.InjectorKeys.SERVICE_UTILITY].openSource(request.correlationId)).check(request);
|
|
69
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
70
|
+
return this._jsonResponse(reply, response);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
get _version() {
|
|
76
|
+
return 'v1';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default UtilityRoute;
|
package/routes/version.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import LibraryServerConstants from '@thzero/library_server/constants.js';
|
|
2
|
-
|
|
3
|
-
import BaseRoute from './index.js';
|
|
4
|
-
|
|
5
|
-
class VersionRoute extends BaseRoute {
|
|
6
|
-
constructor(prefix) {
|
|
7
|
-
super(prefix ? prefix : '');
|
|
8
|
-
|
|
9
|
-
// this._serviceVersion = null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async init(injector, app, config) {
|
|
13
|
-
await super.init(injector, app, config);
|
|
14
|
-
// this._serviceVersion = injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_VERSION);
|
|
15
|
-
this._inject(app, injector, LibraryServerConstants.InjectorKeys.SERVICE_VERSION, LibraryServerConstants.InjectorKeys.SERVICE_VERSION);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
get id() {
|
|
19
|
-
return 'version';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_initializeRoutes(router) {
|
|
23
|
-
router.get(this._join('/version'),
|
|
24
|
-
// eslint-disable-next-line
|
|
25
|
-
async (request, reply) => {
|
|
26
|
-
// const service = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_VERSION);
|
|
27
|
-
const response = (await router[LibraryServerConstants.InjectorKeys.SERVICE_VERSION].version(request.correlationId)).check(request);
|
|
28
|
-
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
29
|
-
return this._jsonResponse(reply, response);
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get _version() {
|
|
35
|
-
return 'v1';
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default VersionRoute;
|
|
1
|
+
import LibraryServerConstants from '@thzero/library_server/constants.js';
|
|
2
|
+
|
|
3
|
+
import BaseRoute from './index.js';
|
|
4
|
+
|
|
5
|
+
class VersionRoute extends BaseRoute {
|
|
6
|
+
constructor(prefix) {
|
|
7
|
+
super(prefix ? prefix : '');
|
|
8
|
+
|
|
9
|
+
// this._serviceVersion = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async init(injector, app, config) {
|
|
13
|
+
await super.init(injector, app, config);
|
|
14
|
+
// this._serviceVersion = injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_VERSION);
|
|
15
|
+
this._inject(app, injector, LibraryServerConstants.InjectorKeys.SERVICE_VERSION, LibraryServerConstants.InjectorKeys.SERVICE_VERSION);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get id() {
|
|
19
|
+
return 'version';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_initializeRoutes(router) {
|
|
23
|
+
router.get(this._join('/version'),
|
|
24
|
+
// eslint-disable-next-line
|
|
25
|
+
async (request, reply) => {
|
|
26
|
+
// const service = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_VERSION);
|
|
27
|
+
const response = (await router[LibraryServerConstants.InjectorKeys.SERVICE_VERSION].version(request.correlationId)).check(request);
|
|
28
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
29
|
+
return this._jsonResponse(reply, response);
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get _version() {
|
|
35
|
+
return 'v1';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default VersionRoute;
|