@thzero/library_server 0.15.9 → 0.15.17
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 +89 -89
- package/boot/index.js +387 -384
- package/boot/koa/index.js +157 -157
- package/boot/plugins/admin/index.js +6 -6
- package/boot/plugins/admin/news.js +35 -35
- package/boot/plugins/admin/users.js +35 -35
- package/boot/plugins/api.js +58 -58
- package/boot/plugins/apiFront.js +31 -31
- package/boot/plugins/index.js +71 -71
- package/boot/plugins/news.js +46 -46
- package/boot/plugins/users.js +48 -48
- package/boot/plugins/usersExtended.js +32 -32
- package/constants.js +45 -45
- package/data/baseNews.js +42 -42
- package/data/baseSettingsUser.js +9 -9
- package/data/baseUser.js +28 -28
- package/data/index.js +24 -24
- package/data/named.js +20 -20
- package/errors/tokenExpired.js +7 -7
- package/license.md +8 -8
- package/middleware/authentication.js +67 -67
- package/middleware/authorization.js +180 -180
- package/package.json +50 -60
- package/repository/index.js +151 -151
- package/repository/usageMetrics/devnull.js +11 -11
- package/routes/admin/index.js +111 -111
- package/routes/admin/news.js +14 -14
- package/routes/admin/users.js +18 -18
- package/routes/baseNews.js +27 -27
- package/routes/baseUsers.js +106 -106
- package/routes/home.js +16 -16
- package/routes/index.js +31 -31
- package/routes/news.js +6 -6
- package/routes/plans.js +24 -24
- package/routes/users.js +6 -6
- package/routes/utility.js +34 -34
- package/routes/version.js +24 -24
- package/service/admin/baseNews.js +45 -45
- package/service/admin/index.js +130 -130
- package/service/admin/news.js +6 -6
- package/service/admin/users.js +107 -107
- package/service/baseSecurity.js +44 -44
- package/service/baseUser.js +122 -122
- package/service/communication.js +6 -6
- package/service/config.js +32 -32
- package/service/crypto.js +16 -16
- package/service/discovery/index.js +6 -6
- package/service/discovery/resources/index.js +101 -101
- package/service/external.js +19 -19
- package/service/externalRest.js +19 -19
- package/service/index.js +20 -20
- package/service/monitoring.js +13 -0
- package/service/news/base.js +49 -49
- package/service/news/index.js +6 -6
- package/service/news/validation/index.js +6 -6
- package/service/plans.js +27 -27
- package/service/restCommunication.js +21 -21
- package/service/usageMetrics.js +63 -63
- package/service/utility.js +37 -37
- package/service/version.js +32 -32
- package/utility/injector.js +59 -59
- package/utility/internalIp/index.js +48 -48
- package/utility/list/doubleLinked.js +88 -88
- package/utility/list/priorityQueue.js +109 -109
- package/utility/list/queue.js +72 -72
- package/utility/os.js +22 -22
package/boot/koa/index.js
CHANGED
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
import Koa from 'koa';
|
|
2
|
-
import koaCors from '@koa/cors';
|
|
3
|
-
import koaHelmet from 'koa-helmet';
|
|
4
|
-
import koaStatic from 'koa-static';
|
|
5
|
-
|
|
6
|
-
import LibraryConstants from '../../constants';
|
|
7
|
-
import Utility from '@thzero/library_common/utility';
|
|
8
|
-
|
|
9
|
-
import TokenExpiredError from '../../errors/tokenExpired';
|
|
10
|
-
|
|
11
|
-
import injector from '@thzero/library_common/utility/injector';
|
|
12
|
-
|
|
13
|
-
import BootMain from '@thzero/library_server/boot';
|
|
14
|
-
|
|
15
|
-
const ResponseTime = 'X-Response-Time';
|
|
16
|
-
|
|
17
|
-
class KoaBootMain extends BootMain {
|
|
18
|
-
async _initApp(args, plugins) {
|
|
19
|
-
const app = new Koa();
|
|
20
|
-
// https://github.com/koajs/cors
|
|
21
|
-
app.use(koaCors({
|
|
22
|
-
allowMethods: 'GET,POST,DELETE',
|
|
23
|
-
maxAge : 7200,
|
|
24
|
-
allowHeaders: `${LibraryConstants.Headers.AuthKeys.API}, ${LibraryConstants.Headers.AuthKeys.AUTH}, ${LibraryConstants.Headers.CorrelationId}, Content-Type`,
|
|
25
|
-
credentials: true,
|
|
26
|
-
origin: '*'
|
|
27
|
-
}));
|
|
28
|
-
// https://www.npmjs.com/package/koa-helmet
|
|
29
|
-
app.use(koaHelmet());
|
|
30
|
-
|
|
31
|
-
// error
|
|
32
|
-
app.use(async (ctx, next) => {
|
|
33
|
-
try {
|
|
34
|
-
await next();
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
ctx.status = err.status || 500;
|
|
38
|
-
if (err instanceof TokenExpiredError) {
|
|
39
|
-
ctx.status = 401;
|
|
40
|
-
ctx.response.header['WWW-Authenticate'] = 'Bearer error="invalid_token", error_description="The access token expired"'
|
|
41
|
-
}
|
|
42
|
-
ctx.app.emit('error', err, ctx);
|
|
43
|
-
await this.usageMetricsServiceI.register(ctx, err).catch(() => {
|
|
44
|
-
this.loggerServiceI.exception('KoaBootMain', 'start', err);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
app.on('error', (err, ctx) => {
|
|
50
|
-
this.loggerServiceI.error('KoaBootMain', 'start', 'Uncaught Exception', err);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// config
|
|
54
|
-
app.use(async (ctx, next) => {
|
|
55
|
-
ctx.config = this._appConfig;
|
|
56
|
-
await next();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// correlationId
|
|
60
|
-
app.use(async (ctx, next) => {
|
|
61
|
-
ctx.correlationId = ctx.request.header[LibraryConstants.Headers.CorrelationId]
|
|
62
|
-
await next();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// logger
|
|
66
|
-
app.use(async (ctx, next) => {
|
|
67
|
-
await next();
|
|
68
|
-
const rt = ctx.response.get(ResponseTime);
|
|
69
|
-
this.loggerServiceI.info2(`${ctx.method} ${ctx.url} - ${rt}`);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// x-response-time
|
|
73
|
-
app.use(async (ctx, next) => {
|
|
74
|
-
const start = Utility.timerStart();
|
|
75
|
-
await next();
|
|
76
|
-
const delta = Utility.timerStop(start, true);
|
|
77
|
-
ctx.set(ResponseTime, delta);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
app.use(koaStatic('./public'));
|
|
81
|
-
|
|
82
|
-
this._initPreAuth(app);
|
|
83
|
-
|
|
84
|
-
// auth-api-token
|
|
85
|
-
app.use(async (ctx, next) => {
|
|
86
|
-
if (ctx.originalUrl === '/favicon.ico') {
|
|
87
|
-
await next();
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const key = ctx.get(LibraryConstants.Headers.AuthKeys.API);
|
|
92
|
-
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.key', key);
|
|
93
|
-
if (!String.isNullOrEmpty(key)) {
|
|
94
|
-
const auth = ctx.config.get('auth');
|
|
95
|
-
if (auth) {
|
|
96
|
-
const apiKey = auth.apiKey;
|
|
97
|
-
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.apiKey', apiKey);
|
|
98
|
-
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.key===apiKey', (key === apiKey));
|
|
99
|
-
if (key === apiKey) {
|
|
100
|
-
ctx.state.apiKey = key;
|
|
101
|
-
await next();
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
(async () => {
|
|
108
|
-
await this.usageMetricsServiceI.register(ctx).catch((err) => {
|
|
109
|
-
this.loggerServiceI.error('KoaBootMain', 'start', 'usageMetrics', err);
|
|
110
|
-
});
|
|
111
|
-
})();
|
|
112
|
-
|
|
113
|
-
console.log('Unauthorized... auth-api-token failure');
|
|
114
|
-
ctx.throw(401);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
this._initPostAuth(app);
|
|
118
|
-
|
|
119
|
-
// usage metrics
|
|
120
|
-
app.use(async (ctx, next) => {
|
|
121
|
-
await next();
|
|
122
|
-
await this.usageMetricsServiceI.register(ctx).catch((err) => {
|
|
123
|
-
this.loggerServiceI.error('KoaBootMain', 'start', 'usageMetrics', err);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
this._routes = [];
|
|
128
|
-
|
|
129
|
-
this._initPreRoutes(app);
|
|
130
|
-
|
|
131
|
-
for (const pluginRoute of plugins)
|
|
132
|
-
await pluginRoute.initRoutes(this._routes);
|
|
133
|
-
|
|
134
|
-
await this._initRoutes();
|
|
135
|
-
|
|
136
|
-
for (const route of this._routes) {
|
|
137
|
-
await route.init(injector)
|
|
138
|
-
app
|
|
139
|
-
.use(route.router.routes())
|
|
140
|
-
.use(route.router.allowedMethods());
|
|
141
|
-
console.log(route.router.stack.map(i => i.path));
|
|
142
|
-
console.log(route.router.stack.map(i => i.methods));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return app;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async _initAppPost(app, args) {
|
|
149
|
-
this._initPostRoutes(app);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
_initRoute(route) {
|
|
153
|
-
this._routes.push(route);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export default KoaBootMain;
|
|
1
|
+
import Koa from 'koa';
|
|
2
|
+
import koaCors from '@koa/cors';
|
|
3
|
+
import koaHelmet from 'koa-helmet';
|
|
4
|
+
import koaStatic from 'koa-static';
|
|
5
|
+
|
|
6
|
+
import LibraryConstants from '../../constants';
|
|
7
|
+
import Utility from '@thzero/library_common/utility';
|
|
8
|
+
|
|
9
|
+
import TokenExpiredError from '../../errors/tokenExpired';
|
|
10
|
+
|
|
11
|
+
import injector from '@thzero/library_common/utility/injector';
|
|
12
|
+
|
|
13
|
+
import BootMain from '@thzero/library_server/boot';
|
|
14
|
+
|
|
15
|
+
const ResponseTime = 'X-Response-Time';
|
|
16
|
+
|
|
17
|
+
class KoaBootMain extends BootMain {
|
|
18
|
+
async _initApp(args, plugins) {
|
|
19
|
+
const app = new Koa();
|
|
20
|
+
// https://github.com/koajs/cors
|
|
21
|
+
app.use(koaCors({
|
|
22
|
+
allowMethods: 'GET,POST,DELETE',
|
|
23
|
+
maxAge : 7200,
|
|
24
|
+
allowHeaders: `${LibraryConstants.Headers.AuthKeys.API}, ${LibraryConstants.Headers.AuthKeys.AUTH}, ${LibraryConstants.Headers.CorrelationId}, Content-Type`,
|
|
25
|
+
credentials: true,
|
|
26
|
+
origin: '*'
|
|
27
|
+
}));
|
|
28
|
+
// https://www.npmjs.com/package/koa-helmet
|
|
29
|
+
app.use(koaHelmet());
|
|
30
|
+
|
|
31
|
+
// error
|
|
32
|
+
app.use(async (ctx, next) => {
|
|
33
|
+
try {
|
|
34
|
+
await next();
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
ctx.status = err.status || 500;
|
|
38
|
+
if (err instanceof TokenExpiredError) {
|
|
39
|
+
ctx.status = 401;
|
|
40
|
+
ctx.response.header['WWW-Authenticate'] = 'Bearer error="invalid_token", error_description="The access token expired"'
|
|
41
|
+
}
|
|
42
|
+
ctx.app.emit('error', err, ctx);
|
|
43
|
+
await this.usageMetricsServiceI.register(ctx, err).catch(() => {
|
|
44
|
+
this.loggerServiceI.exception('KoaBootMain', 'start', err);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
app.on('error', (err, ctx) => {
|
|
50
|
+
this.loggerServiceI.error('KoaBootMain', 'start', 'Uncaught Exception', err);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// config
|
|
54
|
+
app.use(async (ctx, next) => {
|
|
55
|
+
ctx.config = this._appConfig;
|
|
56
|
+
await next();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// correlationId
|
|
60
|
+
app.use(async (ctx, next) => {
|
|
61
|
+
ctx.correlationId = ctx.request.header[LibraryConstants.Headers.CorrelationId]
|
|
62
|
+
await next();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// logger
|
|
66
|
+
app.use(async (ctx, next) => {
|
|
67
|
+
await next();
|
|
68
|
+
const rt = ctx.response.get(ResponseTime);
|
|
69
|
+
this.loggerServiceI.info2(`${ctx.method} ${ctx.url} - ${rt}`);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// x-response-time
|
|
73
|
+
app.use(async (ctx, next) => {
|
|
74
|
+
const start = Utility.timerStart();
|
|
75
|
+
await next();
|
|
76
|
+
const delta = Utility.timerStop(start, true);
|
|
77
|
+
ctx.set(ResponseTime, delta);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
app.use(koaStatic('./public'));
|
|
81
|
+
|
|
82
|
+
this._initPreAuth(app);
|
|
83
|
+
|
|
84
|
+
// auth-api-token
|
|
85
|
+
app.use(async (ctx, next) => {
|
|
86
|
+
if (ctx.originalUrl === '/favicon.ico') {
|
|
87
|
+
await next();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const key = ctx.get(LibraryConstants.Headers.AuthKeys.API);
|
|
92
|
+
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.key', key);
|
|
93
|
+
if (!String.isNullOrEmpty(key)) {
|
|
94
|
+
const auth = ctx.config.get('auth');
|
|
95
|
+
if (auth) {
|
|
96
|
+
const apiKey = auth.apiKey;
|
|
97
|
+
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.apiKey', apiKey);
|
|
98
|
+
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.key===apiKey', (key === apiKey));
|
|
99
|
+
if (key === apiKey) {
|
|
100
|
+
ctx.state.apiKey = key;
|
|
101
|
+
await next();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
(async () => {
|
|
108
|
+
await this.usageMetricsServiceI.register(ctx).catch((err) => {
|
|
109
|
+
this.loggerServiceI.error('KoaBootMain', 'start', 'usageMetrics', err);
|
|
110
|
+
});
|
|
111
|
+
})();
|
|
112
|
+
|
|
113
|
+
console.log('Unauthorized... auth-api-token failure');
|
|
114
|
+
ctx.throw(401);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
this._initPostAuth(app);
|
|
118
|
+
|
|
119
|
+
// usage metrics
|
|
120
|
+
app.use(async (ctx, next) => {
|
|
121
|
+
await next();
|
|
122
|
+
await this.usageMetricsServiceI.register(ctx).catch((err) => {
|
|
123
|
+
this.loggerServiceI.error('KoaBootMain', 'start', 'usageMetrics', err);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
this._routes = [];
|
|
128
|
+
|
|
129
|
+
this._initPreRoutes(app);
|
|
130
|
+
|
|
131
|
+
for (const pluginRoute of plugins)
|
|
132
|
+
await pluginRoute.initRoutes(this._routes);
|
|
133
|
+
|
|
134
|
+
await this._initRoutes();
|
|
135
|
+
|
|
136
|
+
for (const route of this._routes) {
|
|
137
|
+
await route.init(injector)
|
|
138
|
+
app
|
|
139
|
+
.use(route.router.routes())
|
|
140
|
+
.use(route.router.allowedMethods());
|
|
141
|
+
console.log(route.router.stack.map(i => i.path));
|
|
142
|
+
console.log(route.router.stack.map(i => i.methods));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return app;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async _initAppPost(app, args) {
|
|
149
|
+
this._initPostRoutes(app);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
_initRoute(route) {
|
|
153
|
+
this._routes.push(route);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export default KoaBootMain;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BootPlugin from '../index';
|
|
2
|
-
|
|
3
|
-
class AdminBootPlugin extends BootPlugin {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export default AdminBootPlugin;
|
|
1
|
+
import BootPlugin from '../index';
|
|
2
|
+
|
|
3
|
+
class AdminBootPlugin extends BootPlugin {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export default AdminBootPlugin;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import LibraryConstants from '../../../constants';
|
|
2
|
-
|
|
3
|
-
import NotImplementedError from '@thzero/library_common/errors/notImplemented';
|
|
4
|
-
|
|
5
|
-
import AdminBootPlugin from './index';
|
|
6
|
-
|
|
7
|
-
import adminNewsRoute from '../../../routes/admin/news';
|
|
8
|
-
|
|
9
|
-
class NewsAdminBootPlugin extends AdminBootPlugin {
|
|
10
|
-
async _initRoutes() {
|
|
11
|
-
this._initRoute(this._initRoutesAdminNews());
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async _initRepositories() {
|
|
15
|
-
this._injectRepository(LibraryConstants.InjectorKeys.REPOSITORY_ADMIN_NEWS, this._initRepositoriesAdminNews());
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async _initServices() {
|
|
19
|
-
this._injectService(LibraryConstants.InjectorKeys.SERVICE_ADMIN_NEWS, this._initServicesAdminNews());
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_initRepositoriesAdminNews() {
|
|
23
|
-
throw new NotImplementedError();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
_initRoutesAdminNews() {
|
|
27
|
-
return new adminNewsRoute();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
_initServicesAdminNews() {
|
|
31
|
-
throw new NotImplementedError();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default NewsAdminBootPlugin;
|
|
1
|
+
import LibraryConstants from '../../../constants';
|
|
2
|
+
|
|
3
|
+
import NotImplementedError from '@thzero/library_common/errors/notImplemented';
|
|
4
|
+
|
|
5
|
+
import AdminBootPlugin from './index';
|
|
6
|
+
|
|
7
|
+
import adminNewsRoute from '../../../routes/admin/news';
|
|
8
|
+
|
|
9
|
+
class NewsAdminBootPlugin extends AdminBootPlugin {
|
|
10
|
+
async _initRoutes() {
|
|
11
|
+
this._initRoute(this._initRoutesAdminNews());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async _initRepositories() {
|
|
15
|
+
this._injectRepository(LibraryConstants.InjectorKeys.REPOSITORY_ADMIN_NEWS, this._initRepositoriesAdminNews());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async _initServices() {
|
|
19
|
+
this._injectService(LibraryConstants.InjectorKeys.SERVICE_ADMIN_NEWS, this._initServicesAdminNews());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_initRepositoriesAdminNews() {
|
|
23
|
+
throw new NotImplementedError();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_initRoutesAdminNews() {
|
|
27
|
+
return new adminNewsRoute();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_initServicesAdminNews() {
|
|
31
|
+
throw new NotImplementedError();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default NewsAdminBootPlugin;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import LibraryConstants from '../../../constants';
|
|
2
|
-
|
|
3
|
-
import NotImplementedError from '@thzero/library_common/errors/notImplemented';
|
|
4
|
-
|
|
5
|
-
import AdminBootPlugin from './index';
|
|
6
|
-
|
|
7
|
-
import adminUsersRoute from '../../../routes/admin/users'
|
|
8
|
-
|
|
9
|
-
class UsersAdminBootPlugin extends AdminBootPlugin {
|
|
10
|
-
async _initRoutes() {
|
|
11
|
-
this._initRoute(this._initRoutesAdminUsers());
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async _initRepositories() {
|
|
15
|
-
this._injectRepository(LibraryConstants.InjectorKeys.REPOSITORY_ADMIN_USERS, this._initRepositoriesAdminUsers());
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async _initServices() {
|
|
19
|
-
this._injectService(LibraryConstants.InjectorKeys.SERVICE_ADMIN_USERS, this._initServicesAdminUsers());
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_initRepositoriesAdminUsers() {
|
|
23
|
-
throw new NotImplementedError();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
_initRoutesAdminUsers() {
|
|
27
|
-
return new adminUsersRoute();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
_initServicesAdminUsers() {
|
|
31
|
-
throw new NotImplementedError();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default UsersAdminBootPlugin;
|
|
1
|
+
import LibraryConstants from '../../../constants';
|
|
2
|
+
|
|
3
|
+
import NotImplementedError from '@thzero/library_common/errors/notImplemented';
|
|
4
|
+
|
|
5
|
+
import AdminBootPlugin from './index';
|
|
6
|
+
|
|
7
|
+
import adminUsersRoute from '../../../routes/admin/users'
|
|
8
|
+
|
|
9
|
+
class UsersAdminBootPlugin extends AdminBootPlugin {
|
|
10
|
+
async _initRoutes() {
|
|
11
|
+
this._initRoute(this._initRoutesAdminUsers());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async _initRepositories() {
|
|
15
|
+
this._injectRepository(LibraryConstants.InjectorKeys.REPOSITORY_ADMIN_USERS, this._initRepositoriesAdminUsers());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async _initServices() {
|
|
19
|
+
this._injectService(LibraryConstants.InjectorKeys.SERVICE_ADMIN_USERS, this._initServicesAdminUsers());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_initRepositoriesAdminUsers() {
|
|
23
|
+
throw new NotImplementedError();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_initRoutesAdminUsers() {
|
|
27
|
+
return new adminUsersRoute();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_initServicesAdminUsers() {
|
|
31
|
+
throw new NotImplementedError();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default UsersAdminBootPlugin;
|
package/boot/plugins/api.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import LibraryConstants from '../../constants';
|
|
2
|
-
import LibraryCommonServiceConstants from '@thzero/library_common_service/constants';
|
|
3
|
-
|
|
4
|
-
import BootPlugin from './index';
|
|
5
|
-
|
|
6
|
-
import homeRoute from '../../routes/home';
|
|
7
|
-
import versionRoute from '../../routes/version';
|
|
8
|
-
|
|
9
|
-
import cryptoService from '../../service/crypto';
|
|
10
|
-
import versionService from '../../service/version';
|
|
11
|
-
|
|
12
|
-
class ApiBootPlugin extends BootPlugin {
|
|
13
|
-
async _initRoutesPost() {
|
|
14
|
-
this._initRoute(this._initRoutesHome());
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async _initRoutesPre() {
|
|
18
|
-
this._initRoute(this._initRoutesVersion());
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async _initServices() {
|
|
22
|
-
const communicationRestService = this._initServicesCommunicationRest();
|
|
23
|
-
if (communicationRestService)
|
|
24
|
-
this._injectService(LibraryConstants.InjectorKeys.SERVICE_COMMUNICATION_REST, communicationRestService);
|
|
25
|
-
this._injectService(LibraryConstants.InjectorKeys.SERVICE_CRYPTO, this._initServicesCrypto());
|
|
26
|
-
this._injectService(LibraryConstants.InjectorKeys.SERVICE_VERSION, this._initServicesVersion());
|
|
27
|
-
|
|
28
|
-
const validationServices = this._initServicesValidation();
|
|
29
|
-
if (validationServices)
|
|
30
|
-
this._injectService(LibraryCommonServiceConstants.InjectorKeys.SERVICE_VALIDATION, validationServices);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
_initRoutesHome() {
|
|
34
|
-
return new homeRoute();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
_initRoutesVersion() {
|
|
38
|
-
return new versionRoute();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
_initServicesCrypto() {
|
|
42
|
-
return new cryptoService();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_initServicesCommunicationRest() {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
_initServicesValidation() {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
_initServicesVersion() {
|
|
54
|
-
return new versionService();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default ApiBootPlugin;
|
|
1
|
+
import LibraryConstants from '../../constants';
|
|
2
|
+
import LibraryCommonServiceConstants from '@thzero/library_common_service/constants';
|
|
3
|
+
|
|
4
|
+
import BootPlugin from './index';
|
|
5
|
+
|
|
6
|
+
import homeRoute from '../../routes/home';
|
|
7
|
+
import versionRoute from '../../routes/version';
|
|
8
|
+
|
|
9
|
+
import cryptoService from '../../service/crypto';
|
|
10
|
+
import versionService from '../../service/version';
|
|
11
|
+
|
|
12
|
+
class ApiBootPlugin extends BootPlugin {
|
|
13
|
+
async _initRoutesPost() {
|
|
14
|
+
this._initRoute(this._initRoutesHome());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async _initRoutesPre() {
|
|
18
|
+
this._initRoute(this._initRoutesVersion());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async _initServices() {
|
|
22
|
+
const communicationRestService = this._initServicesCommunicationRest();
|
|
23
|
+
if (communicationRestService)
|
|
24
|
+
this._injectService(LibraryConstants.InjectorKeys.SERVICE_COMMUNICATION_REST, communicationRestService);
|
|
25
|
+
this._injectService(LibraryConstants.InjectorKeys.SERVICE_CRYPTO, this._initServicesCrypto());
|
|
26
|
+
this._injectService(LibraryConstants.InjectorKeys.SERVICE_VERSION, this._initServicesVersion());
|
|
27
|
+
|
|
28
|
+
const validationServices = this._initServicesValidation();
|
|
29
|
+
if (validationServices)
|
|
30
|
+
this._injectService(LibraryCommonServiceConstants.InjectorKeys.SERVICE_VALIDATION, validationServices);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_initRoutesHome() {
|
|
34
|
+
return new homeRoute();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_initRoutesVersion() {
|
|
38
|
+
return new versionRoute();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_initServicesCrypto() {
|
|
42
|
+
return new cryptoService();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_initServicesCommunicationRest() {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
_initServicesValidation() {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_initServicesVersion() {
|
|
54
|
+
return new versionService();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default ApiBootPlugin;
|
package/boot/plugins/apiFront.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import LibraryConstants from '../../constants';
|
|
2
|
-
|
|
3
|
-
import ApiBootPlugin from './api';
|
|
4
|
-
|
|
5
|
-
import utilityRoute from '../../routes/utility';
|
|
6
|
-
|
|
7
|
-
import utilityService from '../../service/utility';
|
|
8
|
-
|
|
9
|
-
class FrontApiBootPlugin extends ApiBootPlugin {
|
|
10
|
-
async _initRoutesPre() {
|
|
11
|
-
super._initRoutesPre();
|
|
12
|
-
|
|
13
|
-
this._initRoute(this._initRoutesUtility());
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async _initServices() {
|
|
17
|
-
super._initServices();
|
|
18
|
-
|
|
19
|
-
this._injectService(LibraryConstants.InjectorKeys.SERVICE_UTILITY, this._initServicesUtility());
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_initRoutesUtility() {
|
|
23
|
-
return new utilityRoute();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
_initServicesUtility() {
|
|
27
|
-
return new utilityService();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default FrontApiBootPlugin;
|
|
1
|
+
import LibraryConstants from '../../constants';
|
|
2
|
+
|
|
3
|
+
import ApiBootPlugin from './api';
|
|
4
|
+
|
|
5
|
+
import utilityRoute from '../../routes/utility';
|
|
6
|
+
|
|
7
|
+
import utilityService from '../../service/utility';
|
|
8
|
+
|
|
9
|
+
class FrontApiBootPlugin extends ApiBootPlugin {
|
|
10
|
+
async _initRoutesPre() {
|
|
11
|
+
super._initRoutesPre();
|
|
12
|
+
|
|
13
|
+
this._initRoute(this._initRoutesUtility());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async _initServices() {
|
|
17
|
+
super._initServices();
|
|
18
|
+
|
|
19
|
+
this._injectService(LibraryConstants.InjectorKeys.SERVICE_UTILITY, this._initServicesUtility());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_initRoutesUtility() {
|
|
23
|
+
return new utilityRoute();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_initServicesUtility() {
|
|
27
|
+
return new utilityService();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default FrontApiBootPlugin;
|