@thzero/library_server 0.15.25 → 0.15.28
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 +2 -2
- package/routes/admin/index.js +21 -9
- package/routes/baseNews.js +11 -2
- package/routes/baseUsers.js +22 -9
- package/routes/plans.js +11 -2
- package/routes/utility.js +11 -2
- package/routes/version.js +11 -2
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.28",
|
|
5
5
|
"version_major": 0,
|
|
6
6
|
"version_minor": 15,
|
|
7
|
-
"version_patch":
|
|
7
|
+
"version_patch": 28,
|
|
8
8
|
"version_date": "04/16/2022",
|
|
9
9
|
"description": "An opinionated library of common functionality to bootstrap a Koa based API application using MongoDb and Firebase.",
|
|
10
10
|
"author": "thZero",
|
package/routes/admin/index.js
CHANGED
|
@@ -18,6 +18,14 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
18
18
|
role: role,
|
|
19
19
|
serviceKey: serviceKey
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
// this._service = null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async init(injector, config) {
|
|
26
|
+
const router = await super.init(injector, config);
|
|
27
|
+
router.service = injector.getService(this._options.serviceKey);
|
|
28
|
+
// this._service = injector.getService(this._options.serviceKey);
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
_allowsCreate() {
|
|
@@ -42,8 +50,9 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
42
50
|
}),
|
|
43
51
|
// eslint-disable-next-line
|
|
44
52
|
async (ctx, next) => {
|
|
45
|
-
const service = this._injector.getService(
|
|
46
|
-
const response = (await service.create(ctx.correlationId, ctx.state.user, ctx.request.body)).check(ctx);
|
|
53
|
+
// const service = this._injector.getService(this._options.serviceKey);
|
|
54
|
+
// const response = (await router.service.create(ctx.correlationId, ctx.state.user, ctx.request.body)).check(ctx);
|
|
55
|
+
const response = (await ctx.router.service.create(ctx.correlationId, ctx.state.user, ctx.request.body)).check(ctx);
|
|
47
56
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
48
57
|
}
|
|
49
58
|
);
|
|
@@ -56,8 +65,9 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
56
65
|
authorization([ `${self._options.role}.delete` ]),
|
|
57
66
|
// eslint-disable-next-line
|
|
58
67
|
async (ctx, next) => {
|
|
59
|
-
const service = this._injector.getService(
|
|
60
|
-
const response = (await service.delete(ctx.correlationId, ctx.state.user, ctx.params.id)).check(ctx);
|
|
68
|
+
// const service = this._injector.getService(this._options.serviceKey);
|
|
69
|
+
// const response = (await service.delete(ctx.correlationId, ctx.state.user, ctx.params.id)).check(ctx);
|
|
70
|
+
const response = (await ctx.router.service.delete(ctx.correlationId, ctx.state.user, ctx.params.id)).check(ctx);
|
|
61
71
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
62
72
|
}
|
|
63
73
|
);
|
|
@@ -73,8 +83,9 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
73
83
|
}),
|
|
74
84
|
// eslint-disable-next-line
|
|
75
85
|
async (ctx, next) => {
|
|
76
|
-
const service = this._injector.getService(
|
|
77
|
-
const response = (await service.update(ctx.correlationId, ctx.state.user, ctx.params.id, ctx.request.body)).check(ctx);
|
|
86
|
+
// const service = this._injector.getService(this._options.serviceKey);
|
|
87
|
+
// const response = (await service.update(ctx.correlationId, ctx.state.user, ctx.params.id, ctx.request.body)).check(ctx);
|
|
88
|
+
const response = (await ctx.router.service.update(ctx.correlationId, ctx.state.user, ctx.params.id, ctx.request.body)).check(ctx);
|
|
78
89
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
79
90
|
}
|
|
80
91
|
);
|
|
@@ -92,9 +103,10 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
92
103
|
}),
|
|
93
104
|
// eslint-disable-next-line
|
|
94
105
|
async (ctx, next) => {
|
|
95
|
-
const service = this._injector.getService(this._options.serviceKey);
|
|
96
|
-
const response = (await service.search(ctx.correlationId, ctx.state.user, ctx.request.body)).check(ctx);
|
|
97
|
-
|
|
106
|
+
// const service = this._injector.getService(this._options.serviceKey);
|
|
107
|
+
// const response = (await service.search(ctx.correlationId, ctx.state.user, ctx.request.body)).check(ctx);
|
|
108
|
+
const response = (await ctx.router.service.search(ctx.correlationId, ctx.state.user, ctx.request.body)).check(ctx);
|
|
109
|
+
tthis._jsonResponse(ctx, Utility.stringify(response));
|
|
98
110
|
}
|
|
99
111
|
);
|
|
100
112
|
|
package/routes/baseNews.js
CHANGED
|
@@ -9,6 +9,14 @@ import authentication from '../middleware/authentication';
|
|
|
9
9
|
class BaseNewsRoute extends BaseRoute {
|
|
10
10
|
constructor(prefix, version) {
|
|
11
11
|
super(prefix ? prefix : '/news');
|
|
12
|
+
|
|
13
|
+
// this._serviceNews = null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async init(injector, config) {
|
|
17
|
+
const router = await super.init(injector, config);
|
|
18
|
+
router.serviceNews = injector.getService(LibraryConstants.InjectorKeys.SERVICE_NEWS);
|
|
19
|
+
// this._serviceNews = injector.getService(LibraryConstants.InjectorKeys.SERVICE_NEWS);
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
get id() {
|
|
@@ -20,8 +28,9 @@ class BaseNewsRoute extends BaseRoute {
|
|
|
20
28
|
authentication(false),
|
|
21
29
|
// eslint-disable-next-line
|
|
22
30
|
async (ctx, next) => {
|
|
23
|
-
const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_NEWS);
|
|
24
|
-
const response = (await service.latest(ctx.correlationId, ctx.state.user, parseInt(ctx.params.date))).check(ctx);
|
|
31
|
+
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_NEWS);
|
|
32
|
+
// const response = (await service.latest(ctx.correlationId, ctx.state.user, parseInt(ctx.params.date))).check(ctx);
|
|
33
|
+
const response = (await ctx.router.serviceNews.latest(ctx.correlationId, ctx.state.user, parseInt(ctx.params.date))).check(ctx);
|
|
25
34
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
26
35
|
}
|
|
27
36
|
);
|
package/routes/baseUsers.js
CHANGED
|
@@ -12,6 +12,14 @@ import authorization from '../middleware/authorization';
|
|
|
12
12
|
class BaseUsersRoute extends BaseRoute {
|
|
13
13
|
constructor(prefix, version) {
|
|
14
14
|
super(prefix ? prefix : '/users');
|
|
15
|
+
|
|
16
|
+
// this._serviceUsers = null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async init(injector, config) {
|
|
20
|
+
const router = await super.init(injector, config);
|
|
21
|
+
router.serviceUsers = injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
22
|
+
// this._serviceUsers = injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
get id() {
|
|
@@ -35,8 +43,9 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
35
43
|
}),
|
|
36
44
|
// eslint-disable-next-line
|
|
37
45
|
async (ctx, next) => {
|
|
38
|
-
const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
39
|
-
const response = (await service.fetchByGamerId(ctx.correlationId, ctx.params.gamerId)).check(ctx);
|
|
46
|
+
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
47
|
+
// const response = (await service.fetchByGamerId(ctx.correlationId, ctx.params.gamerId)).check(ctx);
|
|
48
|
+
const response = (await ctx.router.serviceUsers.fetchByGamerId(ctx.correlationId, ctx.params.gamerId)).check(ctx);
|
|
40
49
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
41
50
|
}
|
|
42
51
|
);
|
|
@@ -51,8 +60,9 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
51
60
|
}),
|
|
52
61
|
// eslint-disable-next-line
|
|
53
62
|
async (ctx, next) => {
|
|
54
|
-
const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
55
|
-
const response = (await service.fetchByGamerTag(ctx.correlationId, ctx.params.gamerTag)).check(ctx);
|
|
63
|
+
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
64
|
+
// const response = (await service.fetchByGamerTag(ctx.correlationId, ctx.params.gamerTag)).check(ctx);
|
|
65
|
+
const response = (await ctx.router.serviceUsers.fetchByGamerTag(ctx.correlationId, ctx.params.gamerTag)).check(ctx);
|
|
56
66
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
57
67
|
}
|
|
58
68
|
);
|
|
@@ -67,8 +77,9 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
67
77
|
}),
|
|
68
78
|
// eslint-disable-next-line
|
|
69
79
|
async (ctx, next) => {
|
|
70
|
-
const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
80
|
+
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
71
81
|
const response = (await service.refreshSettings(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
82
|
+
// const response = (await ctx.router.serviceUsers.refreshSettings(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
72
83
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
73
84
|
}
|
|
74
85
|
);
|
|
@@ -83,8 +94,9 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
83
94
|
}),
|
|
84
95
|
// eslint-disable-next-line
|
|
85
96
|
async (ctx, next) => {
|
|
86
|
-
const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
87
|
-
const response = (await service.update(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
97
|
+
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
98
|
+
// const response = (await service.update(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
99
|
+
const response = (await ctx.router.serviceUsers.update(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
88
100
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
89
101
|
}
|
|
90
102
|
);
|
|
@@ -99,8 +111,9 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
99
111
|
}),
|
|
100
112
|
// eslint-disable-next-line
|
|
101
113
|
async (ctx, next) => {
|
|
102
|
-
const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
103
|
-
const response = (await service.updateSettings(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
114
|
+
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
115
|
+
// const response = (await service.updateSettings(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
116
|
+
const response = (await ctx.router.serviceUsers.updateSettings(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
104
117
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
105
118
|
}
|
|
106
119
|
);
|
package/routes/plans.js
CHANGED
|
@@ -7,6 +7,14 @@ import BaseRoute from './index';
|
|
|
7
7
|
class PlansRoute extends BaseRoute {
|
|
8
8
|
constructor(prefix) {
|
|
9
9
|
super(prefix ? prefix : '/plans');
|
|
10
|
+
|
|
11
|
+
// this._servicePlans = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async init(injector, config) {
|
|
15
|
+
const router = await super.init(injector, config);
|
|
16
|
+
router.servicePlans = injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
17
|
+
// this._servicePlans = injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
get id() {
|
|
@@ -17,8 +25,9 @@ class PlansRoute extends BaseRoute {
|
|
|
17
25
|
router.get('/',
|
|
18
26
|
// eslint-disable-next-line
|
|
19
27
|
async (ctx, next) => {
|
|
20
|
-
const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
21
|
-
const response = (await service.listing(ctx.correlationId)).check(ctx);
|
|
28
|
+
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
29
|
+
// const response = (await service.servicePlans.listing(ctx.correlationId)).check(ctx);
|
|
30
|
+
const response = (await ctx.router.servicePlans.listing(ctx.correlationId)).check(ctx);
|
|
22
31
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
23
32
|
}
|
|
24
33
|
);
|
package/routes/utility.js
CHANGED
|
@@ -12,6 +12,14 @@ import authentication from '../middleware/authentication';
|
|
|
12
12
|
class UtilityRoute extends BaseRoute {
|
|
13
13
|
constructor(prefix) {
|
|
14
14
|
super(prefix ? prefix : '/utility');
|
|
15
|
+
|
|
16
|
+
// this._serviceUtility = null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async init(injector, config) {
|
|
20
|
+
const router = await super.init(injector, config);
|
|
21
|
+
router.serviceUtility = injector.getService(LibraryConstants.InjectorKeys.SERVICE_UTILITY);
|
|
22
|
+
// this._serviceUtility = injector.getService(LibraryConstants.InjectorKeys.SERVICE_UTILITY);
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
get id() {
|
|
@@ -27,8 +35,9 @@ class UtilityRoute extends BaseRoute {
|
|
|
27
35
|
text: false,
|
|
28
36
|
}),
|
|
29
37
|
async (ctx, next) => {
|
|
30
|
-
const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_UTILITY);
|
|
31
|
-
const response = (await service.logger(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
38
|
+
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_UTILITY);
|
|
39
|
+
// const response = (await service.logger(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
40
|
+
const response = (await ctx.router.serviceUtility.logger(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
32
41
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
33
42
|
}
|
|
34
43
|
);
|
package/routes/version.js
CHANGED
|
@@ -7,6 +7,14 @@ import BaseRoute from './index';
|
|
|
7
7
|
class VersionRoute extends BaseRoute {
|
|
8
8
|
constructor(prefix) {
|
|
9
9
|
super(prefix ? prefix : '');
|
|
10
|
+
|
|
11
|
+
// this._serviceVersion = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async init(injector, config) {
|
|
15
|
+
const router = await super.init(injector, config);
|
|
16
|
+
router.serviceVersion = injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
17
|
+
// this._serviceVersion = injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
get id() {
|
|
@@ -17,8 +25,9 @@ class VersionRoute extends BaseRoute {
|
|
|
17
25
|
router.get('/version',
|
|
18
26
|
// eslint-disable-next-line
|
|
19
27
|
async (ctx, next) => {
|
|
20
|
-
const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
21
|
-
const response = (await service.version(ctx.correlationId)).check(ctx);
|
|
28
|
+
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
29
|
+
// const response = (await service.version(ctx.correlationId)).check(ctx);
|
|
30
|
+
const response = (await ctx.router.serviceVersion.version(ctx.correlationId)).check(ctx);
|
|
22
31
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
23
32
|
}
|
|
24
33
|
);
|