@thzero/library_server_koa 0.15.38 → 0.15.39
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 +182 -182
- 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 +11 -11
- package/boot/plugins/news.js +11 -11
- package/boot/plugins/users.js +11 -11
- package/boot/plugins/usersExtended.js +11 -11
- package/license.md +8 -8
- package/middleware/authentication.js +83 -83
- package/middleware/authorization.js +191 -191
- package/package.json +39 -39
- package/routes/admin/index.js +123 -123
- package/routes/admin/news.js +22 -22
- package/routes/admin/users.js +26 -26
- package/routes/baseNews.js +40 -40
- package/routes/baseUsers.js +123 -123
- package/routes/home.js +28 -28
- package/routes/index.js +21 -21
- package/routes/news.js +6 -6
- package/routes/plans.js +41 -41
- package/routes/users.js +6 -6
- package/routes/utility.js +51 -51
- package/routes/version.js +41 -41
package/routes/home.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import BaseRoute from './index';
|
|
2
|
-
|
|
3
|
-
class HomeRoute extends BaseRoute {
|
|
4
|
-
constructor(prefix) {
|
|
5
|
-
super(prefix ? prefix : '');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
get id() {
|
|
9
|
-
return 'home';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
_initializeRoutes(router) {
|
|
13
|
-
// eslint-disable-next-line
|
|
14
|
-
router.get('/', (ctx, next) => {
|
|
15
|
-
ctx.status = 404;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get _ignoreApi() {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get _version() {
|
|
24
|
-
return '';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default HomeRoute;
|
|
1
|
+
import BaseRoute from './index';
|
|
2
|
+
|
|
3
|
+
class HomeRoute extends BaseRoute {
|
|
4
|
+
constructor(prefix) {
|
|
5
|
+
super(prefix ? prefix : '');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get id() {
|
|
9
|
+
return 'home';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_initializeRoutes(router) {
|
|
13
|
+
// eslint-disable-next-line
|
|
14
|
+
router.get('/', (ctx, next) => {
|
|
15
|
+
ctx.status = 404;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get _ignoreApi() {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get _version() {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default HomeRoute;
|
package/routes/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import koaRouter from '@koa/router';
|
|
2
|
-
|
|
3
|
-
import BaseRoute from'@thzero/library_server/routes/index';
|
|
4
|
-
|
|
5
|
-
class KoaBaseRoute extends BaseRoute {
|
|
6
|
-
_initializeRouter(app, config) {
|
|
7
|
-
return new koaRouter({
|
|
8
|
-
prefix: this._prefix
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
_jsonResponse(ctx, json) {
|
|
13
|
-
if (!ctx)
|
|
14
|
-
throw Error('Invalid context for response.');
|
|
15
|
-
|
|
16
|
-
ctx.type = 'application/json; charset=utf-8';
|
|
17
|
-
ctx.body = json;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default KoaBaseRoute;
|
|
1
|
+
import koaRouter from '@koa/router';
|
|
2
|
+
|
|
3
|
+
import BaseRoute from'@thzero/library_server/routes/index';
|
|
4
|
+
|
|
5
|
+
class KoaBaseRoute extends BaseRoute {
|
|
6
|
+
_initializeRouter(app, config) {
|
|
7
|
+
return new koaRouter({
|
|
8
|
+
prefix: this._prefix
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_jsonResponse(ctx, json) {
|
|
13
|
+
if (!ctx)
|
|
14
|
+
throw Error('Invalid context for response.');
|
|
15
|
+
|
|
16
|
+
ctx.type = 'application/json; charset=utf-8';
|
|
17
|
+
ctx.body = json;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default KoaBaseRoute;
|
package/routes/news.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BaseNewsRoute from './baseNews';
|
|
2
|
-
|
|
3
|
-
class NewsRoute extends BaseNewsRoute {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export default NewsRoute;
|
|
1
|
+
import BaseNewsRoute from './baseNews';
|
|
2
|
+
|
|
3
|
+
class NewsRoute extends BaseNewsRoute {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export default NewsRoute;
|
package/routes/plans.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import LibraryConstants from '.@thzero/library_server/constants';
|
|
2
|
-
|
|
3
|
-
import Utility from '@thzero/library_common/utility';
|
|
4
|
-
|
|
5
|
-
import BaseRoute from './index';
|
|
6
|
-
|
|
7
|
-
class PlansRoute extends BaseRoute {
|
|
8
|
-
constructor(prefix) {
|
|
9
|
-
super(prefix ? prefix : '/plans');
|
|
10
|
-
|
|
11
|
-
// this._servicePlans = null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async init(injector, app, config) {
|
|
15
|
-
const router = await super.init(injector, app, config);
|
|
16
|
-
router.servicePlans = injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
17
|
-
// this._servicePlans = injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get id() {
|
|
21
|
-
return 'plans';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
_initializeRoutes(router) {
|
|
25
|
-
router.get('/',
|
|
26
|
-
// eslint-disable-next-line
|
|
27
|
-
async (ctx, next) => {
|
|
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);
|
|
31
|
-
this._jsonResponse(ctx, Utility.stringify(response));
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get _version() {
|
|
37
|
-
return 'v1';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default PlansRoute;
|
|
1
|
+
import LibraryConstants from '.@thzero/library_server/constants';
|
|
2
|
+
|
|
3
|
+
import Utility from '@thzero/library_common/utility';
|
|
4
|
+
|
|
5
|
+
import BaseRoute from './index';
|
|
6
|
+
|
|
7
|
+
class PlansRoute extends BaseRoute {
|
|
8
|
+
constructor(prefix) {
|
|
9
|
+
super(prefix ? prefix : '/plans');
|
|
10
|
+
|
|
11
|
+
// this._servicePlans = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async init(injector, app, config) {
|
|
15
|
+
const router = await super.init(injector, app, config);
|
|
16
|
+
router.servicePlans = injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
17
|
+
// this._servicePlans = injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get id() {
|
|
21
|
+
return 'plans';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_initializeRoutes(router) {
|
|
25
|
+
router.get('/',
|
|
26
|
+
// eslint-disable-next-line
|
|
27
|
+
async (ctx, next) => {
|
|
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);
|
|
31
|
+
this._jsonResponse(ctx, Utility.stringify(response));
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get _version() {
|
|
37
|
+
return 'v1';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default PlansRoute;
|
package/routes/users.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BaseUsersRoute from './baseUsers';
|
|
2
|
-
|
|
3
|
-
class UsersRoute extends BaseUsersRoute {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export default UsersRoute;
|
|
1
|
+
import BaseUsersRoute from './baseUsers';
|
|
2
|
+
|
|
3
|
+
class UsersRoute extends BaseUsersRoute {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export default UsersRoute;
|
package/routes/utility.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import koaBody from 'koa-body';
|
|
2
|
-
|
|
3
|
-
import LibraryConstants from '@thzero/library_server/constants';
|
|
4
|
-
|
|
5
|
-
import Utility from '@thzero/library_common/utility';
|
|
6
|
-
|
|
7
|
-
import BaseRoute from './index';
|
|
8
|
-
|
|
9
|
-
import authentication from '../middleware/authentication';
|
|
10
|
-
// import authorization from '../middleware/authorization';
|
|
11
|
-
|
|
12
|
-
class UtilityRoute extends BaseRoute {
|
|
13
|
-
constructor(prefix) {
|
|
14
|
-
super(prefix ? prefix : '/utility');
|
|
15
|
-
|
|
16
|
-
// this._serviceUtility = null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async init(injector, app, config) {
|
|
20
|
-
const router = await super.init(injector, app, config);
|
|
21
|
-
router.serviceUtility = injector.getService(LibraryConstants.InjectorKeys.SERVICE_UTILITY);
|
|
22
|
-
// this._serviceUtility = injector.getService(LibraryConstants.InjectorKeys.SERVICE_UTILITY);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get id() {
|
|
26
|
-
return 'utility';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
_initializeRoutes(router) {
|
|
30
|
-
router.post('/logger',
|
|
31
|
-
authentication(false),
|
|
32
|
-
// authorization('utility'),
|
|
33
|
-
// eslint-disable-next-line,
|
|
34
|
-
koaBody({
|
|
35
|
-
text: false,
|
|
36
|
-
}),
|
|
37
|
-
async (ctx, next) => {
|
|
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);
|
|
41
|
-
this._jsonResponse(ctx, Utility.stringify(response));
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get _version() {
|
|
47
|
-
return 'v1';
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default UtilityRoute;
|
|
1
|
+
import koaBody from 'koa-body';
|
|
2
|
+
|
|
3
|
+
import LibraryConstants from '@thzero/library_server/constants';
|
|
4
|
+
|
|
5
|
+
import Utility from '@thzero/library_common/utility';
|
|
6
|
+
|
|
7
|
+
import BaseRoute from './index';
|
|
8
|
+
|
|
9
|
+
import authentication from '../middleware/authentication';
|
|
10
|
+
// import authorization from '../middleware/authorization';
|
|
11
|
+
|
|
12
|
+
class UtilityRoute extends BaseRoute {
|
|
13
|
+
constructor(prefix) {
|
|
14
|
+
super(prefix ? prefix : '/utility');
|
|
15
|
+
|
|
16
|
+
// this._serviceUtility = null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async init(injector, app, config) {
|
|
20
|
+
const router = await super.init(injector, app, config);
|
|
21
|
+
router.serviceUtility = injector.getService(LibraryConstants.InjectorKeys.SERVICE_UTILITY);
|
|
22
|
+
// this._serviceUtility = injector.getService(LibraryConstants.InjectorKeys.SERVICE_UTILITY);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get id() {
|
|
26
|
+
return 'utility';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_initializeRoutes(router) {
|
|
30
|
+
router.post('/logger',
|
|
31
|
+
authentication(false),
|
|
32
|
+
// authorization('utility'),
|
|
33
|
+
// eslint-disable-next-line,
|
|
34
|
+
koaBody({
|
|
35
|
+
text: false,
|
|
36
|
+
}),
|
|
37
|
+
async (ctx, next) => {
|
|
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);
|
|
41
|
+
this._jsonResponse(ctx, Utility.stringify(response));
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get _version() {
|
|
47
|
+
return 'v1';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default UtilityRoute;
|
package/routes/version.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import LibraryConstants from '@thzero/library_server/constants';
|
|
2
|
-
|
|
3
|
-
import Utility from '@thzero/library_common/utility';
|
|
4
|
-
|
|
5
|
-
import BaseRoute from './index';
|
|
6
|
-
|
|
7
|
-
class VersionRoute extends BaseRoute {
|
|
8
|
-
constructor(prefix) {
|
|
9
|
-
super(prefix ? prefix : '');
|
|
10
|
-
|
|
11
|
-
// this._serviceVersion = null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async init(injector, app, config) {
|
|
15
|
-
const router = await super.init(injector, app, config);
|
|
16
|
-
router.serviceVersion = injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
17
|
-
// this._serviceVersion = injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get id() {
|
|
21
|
-
return 'version';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
_initializeRoutes(router) {
|
|
25
|
-
router.get('/version',
|
|
26
|
-
// eslint-disable-next-line
|
|
27
|
-
async (ctx, next) => {
|
|
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);
|
|
31
|
-
this._jsonResponse(ctx, Utility.stringify(response));
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get _version() {
|
|
37
|
-
return 'v1';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default VersionRoute;
|
|
1
|
+
import LibraryConstants from '@thzero/library_server/constants';
|
|
2
|
+
|
|
3
|
+
import Utility from '@thzero/library_common/utility';
|
|
4
|
+
|
|
5
|
+
import BaseRoute from './index';
|
|
6
|
+
|
|
7
|
+
class VersionRoute extends BaseRoute {
|
|
8
|
+
constructor(prefix) {
|
|
9
|
+
super(prefix ? prefix : '');
|
|
10
|
+
|
|
11
|
+
// this._serviceVersion = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async init(injector, app, config) {
|
|
15
|
+
const router = await super.init(injector, app, config);
|
|
16
|
+
router.serviceVersion = injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
17
|
+
// this._serviceVersion = injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get id() {
|
|
21
|
+
return 'version';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_initializeRoutes(router) {
|
|
25
|
+
router.get('/version',
|
|
26
|
+
// eslint-disable-next-line
|
|
27
|
+
async (ctx, next) => {
|
|
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);
|
|
31
|
+
this._jsonResponse(ctx, Utility.stringify(response));
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get _version() {
|
|
37
|
+
return 'v1';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default VersionRoute;
|