@thzero/library_server 0.15.25 → 0.15.26
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 +11 -6
- package/routes/baseNews.js +9 -2
- package/routes/baseUsers.js +13 -10
- package/routes/plans.js +9 -2
- package/routes/utility.js +9 -2
- package/routes/version.js +9 -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.26",
|
|
5
5
|
"version_major": 0,
|
|
6
6
|
"version_minor": 15,
|
|
7
|
-
"version_patch":
|
|
7
|
+
"version_patch": 26,
|
|
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,7 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
42
50
|
}),
|
|
43
51
|
// eslint-disable-next-line
|
|
44
52
|
async (ctx, next) => {
|
|
45
|
-
const
|
|
46
|
-
const response = (await service.create(ctx.correlationId, ctx.state.user, ctx.request.body)).check(ctx);
|
|
53
|
+
const response = (await router.service.create(ctx.correlationId, ctx.state.user, ctx.request.body)).check(ctx);
|
|
47
54
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
48
55
|
}
|
|
49
56
|
);
|
|
@@ -56,8 +63,7 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
56
63
|
authorization([ `${self._options.role}.delete` ]),
|
|
57
64
|
// eslint-disable-next-line
|
|
58
65
|
async (ctx, next) => {
|
|
59
|
-
const
|
|
60
|
-
const response = (await service.delete(ctx.correlationId, ctx.state.user, ctx.params.id)).check(ctx);
|
|
66
|
+
const response = (await router.service.delete(ctx.correlationId, ctx.state.user, ctx.params.id)).check(ctx);
|
|
61
67
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
62
68
|
}
|
|
63
69
|
);
|
|
@@ -73,8 +79,7 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
73
79
|
}),
|
|
74
80
|
// eslint-disable-next-line
|
|
75
81
|
async (ctx, next) => {
|
|
76
|
-
const
|
|
77
|
-
const response = (await service.update(ctx.correlationId, ctx.state.user, ctx.params.id, ctx.request.body)).check(ctx);
|
|
82
|
+
const response = (await router.service.update(ctx.correlationId, ctx.state.user, ctx.params.id, ctx.request.body)).check(ctx);
|
|
78
83
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
79
84
|
}
|
|
80
85
|
);
|
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,7 @@ class BaseNewsRoute extends BaseRoute {
|
|
|
20
28
|
authentication(false),
|
|
21
29
|
// eslint-disable-next-line
|
|
22
30
|
async (ctx, next) => {
|
|
23
|
-
const
|
|
24
|
-
const response = (await service.latest(ctx.correlationId, ctx.state.user, parseInt(ctx.params.date))).check(ctx);
|
|
31
|
+
const response = (await ctx.router.serviceNews.latest(ctx.correlationId, ctx.state.user, parseInt(ctx.params.date))).check(ctx);
|
|
25
32
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
26
33
|
}
|
|
27
34
|
);
|
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,7 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
35
43
|
}),
|
|
36
44
|
// eslint-disable-next-line
|
|
37
45
|
async (ctx, next) => {
|
|
38
|
-
const
|
|
39
|
-
const response = (await service.fetchByGamerId(ctx.correlationId, ctx.params.gamerId)).check(ctx);
|
|
46
|
+
const response = (await ctx.router.serviceUsers.fetchByGamerId(ctx.correlationId, ctx.params.gamerId)).check(ctx);
|
|
40
47
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
41
48
|
}
|
|
42
49
|
);
|
|
@@ -51,8 +58,7 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
51
58
|
}),
|
|
52
59
|
// eslint-disable-next-line
|
|
53
60
|
async (ctx, next) => {
|
|
54
|
-
const
|
|
55
|
-
const response = (await service.fetchByGamerTag(ctx.correlationId, ctx.params.gamerTag)).check(ctx);
|
|
61
|
+
const response = (await ctx.router.serviceUsers.fetchByGamerTag(ctx.correlationId, ctx.params.gamerTag)).check(ctx);
|
|
56
62
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
57
63
|
}
|
|
58
64
|
);
|
|
@@ -67,8 +73,7 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
67
73
|
}),
|
|
68
74
|
// eslint-disable-next-line
|
|
69
75
|
async (ctx, next) => {
|
|
70
|
-
const
|
|
71
|
-
const response = (await service.refreshSettings(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
76
|
+
const response = (await ctx.router.serviceUsers.refreshSettings(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
72
77
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
73
78
|
}
|
|
74
79
|
);
|
|
@@ -83,8 +88,7 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
83
88
|
}),
|
|
84
89
|
// eslint-disable-next-line
|
|
85
90
|
async (ctx, next) => {
|
|
86
|
-
const
|
|
87
|
-
const response = (await service.update(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
91
|
+
const response = (await ctx.router.serviceUsers.update(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
88
92
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
89
93
|
}
|
|
90
94
|
);
|
|
@@ -99,8 +103,7 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
99
103
|
}),
|
|
100
104
|
// eslint-disable-next-line
|
|
101
105
|
async (ctx, next) => {
|
|
102
|
-
const
|
|
103
|
-
const response = (await service.updateSettings(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
106
|
+
const response = (await ctx.router.serviceUsers.updateSettings(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
104
107
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
105
108
|
}
|
|
106
109
|
);
|
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,7 @@ class PlansRoute extends BaseRoute {
|
|
|
17
25
|
router.get('/',
|
|
18
26
|
// eslint-disable-next-line
|
|
19
27
|
async (ctx, next) => {
|
|
20
|
-
const
|
|
21
|
-
const response = (await service.listing(ctx.correlationId)).check(ctx);
|
|
28
|
+
const response = (await router.servicePlans.listing(ctx.correlationId)).check(ctx);
|
|
22
29
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
23
30
|
}
|
|
24
31
|
);
|
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,7 @@ class UtilityRoute extends BaseRoute {
|
|
|
27
35
|
text: false,
|
|
28
36
|
}),
|
|
29
37
|
async (ctx, next) => {
|
|
30
|
-
const
|
|
31
|
-
const response = (await service.logger(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
38
|
+
const response = (await ctx.router.serviceUtility.logger(ctx.correlationId, ctx.request.body)).check(ctx);
|
|
32
39
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
33
40
|
}
|
|
34
41
|
);
|
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,7 @@ class VersionRoute extends BaseRoute {
|
|
|
17
25
|
router.get('/version',
|
|
18
26
|
// eslint-disable-next-line
|
|
19
27
|
async (ctx, next) => {
|
|
20
|
-
const
|
|
21
|
-
const response = (await service.version(ctx.correlationId)).check(ctx);
|
|
28
|
+
const response = (await ctx.router.serviceVersion.version(ctx.correlationId)).check(ctx);
|
|
22
29
|
this._jsonResponse(ctx, Utility.stringify(response));
|
|
23
30
|
}
|
|
24
31
|
);
|