@thzero/library_server_koa 18.0.17 → 18.0.19
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/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-

|
|
2
|
-

|
|
3
|
-
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
|
|
5
|
-
# library_server_koa
|
|
6
|
-
|
|
7
|
-
An opinionated library of common functionality to bootstrap a Koa based API application.
|
|
8
|
-
|
|
9
|
-
## Requirements
|
|
10
|
-
|
|
11
|
-
### NodeJs
|
|
12
|
-
|
|
13
|
-
[NodeJs](https://nodejs.org) version 18+
|
|
14
|
-
|
|
15
|
-
### Installation
|
|
16
|
-
|
|
17
|
-
[](https://npmjs.org/package/@thzero/library_server_koa)
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
|
|
5
|
+
# library_server_koa
|
|
6
|
+
|
|
7
|
+
An opinionated library of common functionality to bootstrap a Koa based API application.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
### NodeJs
|
|
12
|
+
|
|
13
|
+
[NodeJs](https://nodejs.org) version 18+
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
[](https://npmjs.org/package/@thzero/library_server_koa)
|
package/boot/index.js
CHANGED
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
|
|
3
|
-
import Koa from 'koa';
|
|
4
|
-
import koaCors from '@koa/cors';
|
|
5
|
-
import koaHelmet from 'koa-helmet';
|
|
6
|
-
import koaStatic from 'koa-static';
|
|
7
|
-
|
|
8
|
-
import LibraryConstants from '@thzero/library_server/constants';
|
|
9
|
-
import Utility from '@thzero/library_common/utility';
|
|
10
|
-
|
|
11
|
-
import TokenExpiredError from '@thzero/library_server/errors/tokenExpired';
|
|
12
|
-
|
|
13
|
-
import injector from '@thzero/library_common/utility/injector';
|
|
14
|
-
|
|
15
|
-
import BootMain from '@thzero/library_server/boot';
|
|
16
|
-
|
|
17
|
-
const ResponseTime = 'X-Response-Time';
|
|
18
|
-
|
|
19
|
-
class KoaBootMain extends BootMain {
|
|
20
|
-
async _initApp(args, plugins) {
|
|
21
|
-
const app = new Koa();
|
|
22
|
-
|
|
23
|
-
// https://github.com/koajs/cors
|
|
24
|
-
app.use(koaCors({
|
|
25
|
-
allowMethods: 'GET,POST,DELETE',
|
|
26
|
-
maxAge : 7200,
|
|
27
|
-
allowHeaders: `${LibraryConstants.Headers.AuthKeys.API}, ${LibraryConstants.Headers.AuthKeys.AUTH}, ${LibraryConstants.Headers.CorrelationId}, Content-Type`,
|
|
28
|
-
credentials: true,
|
|
29
|
-
origin: '*'
|
|
30
|
-
}));
|
|
31
|
-
// https://www.npmjs.com/package/koa-helmet
|
|
32
|
-
app.use(koaHelmet());
|
|
33
|
-
|
|
34
|
-
// error
|
|
35
|
-
app.use(async (ctx, next) => {
|
|
36
|
-
try {
|
|
37
|
-
await next();
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
ctx.status = err.status || 500;
|
|
41
|
-
if (err instanceof TokenExpiredError) {
|
|
42
|
-
ctx.status = 401;
|
|
43
|
-
ctx.response.header['WWW-Authenticate'] = 'Bearer error="invalid_token", error_description="The access token expired"'
|
|
44
|
-
}
|
|
45
|
-
ctx.app.emit('error', err, ctx);
|
|
46
|
-
await this.usageMetricsServiceI.register(ctx, err).catch(() => {
|
|
47
|
-
this.loggerServiceI.exception('KoaBootMain', 'start', err);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
app.on('error', (err, ctx) => {
|
|
53
|
-
this.loggerServiceI.error('KoaBootMain', 'start', 'Uncaught Exception', err);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// config
|
|
57
|
-
app.use(async (ctx, next) => {
|
|
58
|
-
ctx.config = this._appConfig;
|
|
59
|
-
await next();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// correlationId
|
|
63
|
-
app.use(async (ctx, next) => {
|
|
64
|
-
ctx.correlationId = ctx.request.header[LibraryConstants.Headers.CorrelationId]
|
|
65
|
-
await next();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// logger
|
|
69
|
-
app.use(async (ctx, next) => {
|
|
70
|
-
await next();
|
|
71
|
-
const rt = ctx.response.get(ResponseTime);
|
|
72
|
-
this.loggerServiceI.info2(`${ctx.method} ${ctx.url} - ${rt}`);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// x-response-time
|
|
76
|
-
app.use(async (ctx, next) => {
|
|
77
|
-
const start = Utility.timerStart();
|
|
78
|
-
await next();
|
|
79
|
-
const delta = Utility.timerStop(start, true);
|
|
80
|
-
ctx.set(ResponseTime, delta);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
app.use(koaStatic('./public'));
|
|
84
|
-
|
|
85
|
-
this._initPreAuth(app);
|
|
86
|
-
|
|
87
|
-
// auth-api-token
|
|
88
|
-
app.use(async (ctx, next) => {
|
|
89
|
-
if (ctx.originalUrl === '/favicon.ico') {
|
|
90
|
-
await next();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const key = ctx.get(LibraryConstants.Headers.AuthKeys.API);
|
|
95
|
-
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.key', key);
|
|
96
|
-
if (!String.isNullOrEmpty(key)) {
|
|
97
|
-
const auth = ctx.config.get('auth');
|
|
98
|
-
if (auth) {
|
|
99
|
-
const apiKey = auth.apiKey;
|
|
100
|
-
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.apiKey', apiKey);
|
|
101
|
-
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.key===apiKey', (key === apiKey));
|
|
102
|
-
if (key === apiKey) {
|
|
103
|
-
ctx.state.apiKey = key;
|
|
104
|
-
await next();
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
(async () => {
|
|
111
|
-
const usageMetrics = {};
|
|
112
|
-
usageMetrics.url = ctx.request.path;
|
|
113
|
-
usageMetrics.correlationId = ctx.correlationId;
|
|
114
|
-
usageMetrics.href = ctx.request.href;
|
|
115
|
-
usageMetrics.headers = ctx.request.headers;
|
|
116
|
-
usageMetrics.host = ctx.request.host;
|
|
117
|
-
usageMetrics.hostname = ctx.request.hostname;
|
|
118
|
-
usageMetrics.querystring = ctx.request.querystring;
|
|
119
|
-
usageMetrics.type = ctx.request.type;
|
|
120
|
-
usageMetrics.token = ctx.request.token;
|
|
121
|
-
await this.usageMetricsServiceI.register(usageMetrics).catch((err) => {
|
|
122
|
-
this.loggerServiceI.error('KoaBootMain', 'start', 'usageMetrics', err);
|
|
123
|
-
});
|
|
124
|
-
})();
|
|
125
|
-
|
|
126
|
-
console.log('Unauthorized... auth-api-token failure');
|
|
127
|
-
ctx.throw(401);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
this._initPostAuth(app);
|
|
131
|
-
|
|
132
|
-
// usage metrics
|
|
133
|
-
app.use(async (ctx, next) => {
|
|
134
|
-
await next();
|
|
135
|
-
await this.usageMetricsServiceI.register(ctx).catch((err) => {
|
|
136
|
-
this.loggerServiceI.error('KoaBootMain', 'start', 'usageMetrics', err);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
this._routes = [];
|
|
141
|
-
|
|
142
|
-
this._initPreRoutes(app);
|
|
143
|
-
|
|
144
|
-
for (const pluginRoute of plugins)
|
|
145
|
-
await pluginRoute.initRoutes(this._routes);
|
|
146
|
-
|
|
147
|
-
await this._initRoutes();
|
|
148
|
-
|
|
149
|
-
console.log();
|
|
150
|
-
|
|
151
|
-
for (const route of this._routes) {
|
|
152
|
-
await route.init(injector, app, this._appConfig);
|
|
153
|
-
app
|
|
154
|
-
.use(route.router.routes())
|
|
155
|
-
.use(route.router.allowedMethods());
|
|
156
|
-
|
|
157
|
-
console.log([ route.id ]);
|
|
158
|
-
|
|
159
|
-
for (let i = 0; i < route.router.stack.length; i++)
|
|
160
|
-
console.log([ route.router.stack[i].path, route.router.stack[i].methods ]);
|
|
161
|
-
|
|
162
|
-
console.log();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const serverHttp = http.createServer(app.callback());
|
|
166
|
-
return { app: app, server: serverHttp, listen: serverHttp.listen };
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
_initAppListen(app, server, port, err) {
|
|
170
|
-
server.listen(port, err);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
async _initAppPost(app, args) {
|
|
174
|
-
this._initPostRoutes(app);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
_initRoute(route) {
|
|
178
|
-
this._routes.push(route);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export default KoaBootMain;
|
|
1
|
+
import http from 'http';
|
|
2
|
+
|
|
3
|
+
import Koa from 'koa';
|
|
4
|
+
import koaCors from '@koa/cors';
|
|
5
|
+
import koaHelmet from 'koa-helmet';
|
|
6
|
+
import koaStatic from 'koa-static';
|
|
7
|
+
|
|
8
|
+
import LibraryConstants from '@thzero/library_server/constants';
|
|
9
|
+
import Utility from '@thzero/library_common/utility';
|
|
10
|
+
|
|
11
|
+
import TokenExpiredError from '@thzero/library_server/errors/tokenExpired';
|
|
12
|
+
|
|
13
|
+
import injector from '@thzero/library_common/utility/injector';
|
|
14
|
+
|
|
15
|
+
import BootMain from '@thzero/library_server/boot';
|
|
16
|
+
|
|
17
|
+
const ResponseTime = 'X-Response-Time';
|
|
18
|
+
|
|
19
|
+
class KoaBootMain extends BootMain {
|
|
20
|
+
async _initApp(args, plugins) {
|
|
21
|
+
const app = new Koa();
|
|
22
|
+
|
|
23
|
+
// https://github.com/koajs/cors
|
|
24
|
+
app.use(koaCors({
|
|
25
|
+
allowMethods: 'GET,POST,DELETE',
|
|
26
|
+
maxAge : 7200,
|
|
27
|
+
allowHeaders: `${LibraryConstants.Headers.AuthKeys.API}, ${LibraryConstants.Headers.AuthKeys.AUTH}, ${LibraryConstants.Headers.CorrelationId}, Content-Type`,
|
|
28
|
+
credentials: true,
|
|
29
|
+
origin: '*'
|
|
30
|
+
}));
|
|
31
|
+
// https://www.npmjs.com/package/koa-helmet
|
|
32
|
+
app.use(koaHelmet());
|
|
33
|
+
|
|
34
|
+
// error
|
|
35
|
+
app.use(async (ctx, next) => {
|
|
36
|
+
try {
|
|
37
|
+
await next();
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
ctx.status = err.status || 500;
|
|
41
|
+
if (err instanceof TokenExpiredError) {
|
|
42
|
+
ctx.status = 401;
|
|
43
|
+
ctx.response.header['WWW-Authenticate'] = 'Bearer error="invalid_token", error_description="The access token expired"'
|
|
44
|
+
}
|
|
45
|
+
ctx.app.emit('error', err, ctx);
|
|
46
|
+
await this.usageMetricsServiceI.register(ctx, err).catch(() => {
|
|
47
|
+
this.loggerServiceI.exception('KoaBootMain', 'start', err);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
app.on('error', (err, ctx) => {
|
|
53
|
+
this.loggerServiceI.error('KoaBootMain', 'start', 'Uncaught Exception', err);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// config
|
|
57
|
+
app.use(async (ctx, next) => {
|
|
58
|
+
ctx.config = this._appConfig;
|
|
59
|
+
await next();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// correlationId
|
|
63
|
+
app.use(async (ctx, next) => {
|
|
64
|
+
ctx.correlationId = ctx.request.header[LibraryConstants.Headers.CorrelationId]
|
|
65
|
+
await next();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// logger
|
|
69
|
+
app.use(async (ctx, next) => {
|
|
70
|
+
await next();
|
|
71
|
+
const rt = ctx.response.get(ResponseTime);
|
|
72
|
+
this.loggerServiceI.info2(`${ctx.method} ${ctx.url} - ${rt}`);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// x-response-time
|
|
76
|
+
app.use(async (ctx, next) => {
|
|
77
|
+
const start = Utility.timerStart();
|
|
78
|
+
await next();
|
|
79
|
+
const delta = Utility.timerStop(start, true);
|
|
80
|
+
ctx.set(ResponseTime, delta);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
app.use(koaStatic('./public'));
|
|
84
|
+
|
|
85
|
+
this._initPreAuth(app);
|
|
86
|
+
|
|
87
|
+
// auth-api-token
|
|
88
|
+
app.use(async (ctx, next) => {
|
|
89
|
+
if (ctx.originalUrl === '/favicon.ico') {
|
|
90
|
+
await next();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const key = ctx.get(LibraryConstants.Headers.AuthKeys.API);
|
|
95
|
+
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.key', key);
|
|
96
|
+
if (!String.isNullOrEmpty(key)) {
|
|
97
|
+
const auth = ctx.config.get('auth');
|
|
98
|
+
if (auth) {
|
|
99
|
+
const apiKey = auth.apiKey;
|
|
100
|
+
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.apiKey', apiKey);
|
|
101
|
+
// this.loggerServiceI.debug('KoaBootMain', 'start', 'auth-api-token.key===apiKey', (key === apiKey));
|
|
102
|
+
if (key === apiKey) {
|
|
103
|
+
ctx.state.apiKey = key;
|
|
104
|
+
await next();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
(async () => {
|
|
111
|
+
const usageMetrics = {};
|
|
112
|
+
usageMetrics.url = ctx.request.path;
|
|
113
|
+
usageMetrics.correlationId = ctx.correlationId;
|
|
114
|
+
usageMetrics.href = ctx.request.href;
|
|
115
|
+
usageMetrics.headers = ctx.request.headers;
|
|
116
|
+
usageMetrics.host = ctx.request.host;
|
|
117
|
+
usageMetrics.hostname = ctx.request.hostname;
|
|
118
|
+
usageMetrics.querystring = ctx.request.querystring;
|
|
119
|
+
usageMetrics.type = ctx.request.type;
|
|
120
|
+
usageMetrics.token = ctx.request.token;
|
|
121
|
+
await this.usageMetricsServiceI.register(usageMetrics).catch((err) => {
|
|
122
|
+
this.loggerServiceI.error('KoaBootMain', 'start', 'usageMetrics', err);
|
|
123
|
+
});
|
|
124
|
+
})();
|
|
125
|
+
|
|
126
|
+
console.log('Unauthorized... auth-api-token failure');
|
|
127
|
+
ctx.throw(401);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
this._initPostAuth(app);
|
|
131
|
+
|
|
132
|
+
// usage metrics
|
|
133
|
+
app.use(async (ctx, next) => {
|
|
134
|
+
await next();
|
|
135
|
+
await this.usageMetricsServiceI.register(ctx).catch((err) => {
|
|
136
|
+
this.loggerServiceI.error('KoaBootMain', 'start', 'usageMetrics', err);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
this._routes = [];
|
|
141
|
+
|
|
142
|
+
this._initPreRoutes(app);
|
|
143
|
+
|
|
144
|
+
for (const pluginRoute of plugins)
|
|
145
|
+
await pluginRoute.initRoutes(this._routes);
|
|
146
|
+
|
|
147
|
+
await this._initRoutes();
|
|
148
|
+
|
|
149
|
+
console.log();
|
|
150
|
+
|
|
151
|
+
for (const route of this._routes) {
|
|
152
|
+
await route.init(injector, app, this._appConfig);
|
|
153
|
+
app
|
|
154
|
+
.use(route.router.routes())
|
|
155
|
+
.use(route.router.allowedMethods());
|
|
156
|
+
|
|
157
|
+
console.log([ route.id ]);
|
|
158
|
+
|
|
159
|
+
for (let i = 0; i < route.router.stack.length; i++)
|
|
160
|
+
console.log([ route.router.stack[i].path, route.router.stack[i].methods ]);
|
|
161
|
+
|
|
162
|
+
console.log();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const serverHttp = http.createServer(app.callback());
|
|
166
|
+
return { app: app, server: serverHttp, listen: serverHttp.listen };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_initAppListen(app, server, port, err) {
|
|
170
|
+
server.listen(port, err);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async _initAppPost(app, args) {
|
|
174
|
+
this._initPostRoutes(app);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
_initRoute(route) {
|
|
178
|
+
this._routes.push(route);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export default KoaBootMain;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import BaseNewsAdminBootPlugin from '@thzero/library_server/boot/plugins/admin/news';
|
|
2
|
-
|
|
3
|
-
import adminNewsRoute from '../../../routes/admin/news';
|
|
4
|
-
|
|
5
|
-
class NewsAdminBootPlugin extends BaseNewsAdminBootPlugin {
|
|
6
|
-
_initRoutesAdminNews() {
|
|
7
|
-
return new adminNewsRoute();
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default NewsAdminBootPlugin;
|
|
1
|
+
import BaseNewsAdminBootPlugin from '@thzero/library_server/boot/plugins/admin/news';
|
|
2
|
+
|
|
3
|
+
import adminNewsRoute from '../../../routes/admin/news';
|
|
4
|
+
|
|
5
|
+
class NewsAdminBootPlugin extends BaseNewsAdminBootPlugin {
|
|
6
|
+
_initRoutesAdminNews() {
|
|
7
|
+
return new adminNewsRoute();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default NewsAdminBootPlugin;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import BaseUsersAdminBootPlugin from '@thzero/library_server/boot/plugins/admin/users';
|
|
2
|
-
|
|
3
|
-
import adminUsersRoute from '../../../routes/admin/users'
|
|
4
|
-
|
|
5
|
-
class UsersAdminBootPlugin extends BaseUsersAdminBootPlugin {
|
|
6
|
-
_initRoutesAdminUsers() {
|
|
7
|
-
return new adminUsersRoute();
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default UsersAdminBootPlugin;
|
|
1
|
+
import BaseUsersAdminBootPlugin from '@thzero/library_server/boot/plugins/admin/users';
|
|
2
|
+
|
|
3
|
+
import adminUsersRoute from '../../../routes/admin/users'
|
|
4
|
+
|
|
5
|
+
class UsersAdminBootPlugin extends BaseUsersAdminBootPlugin {
|
|
6
|
+
_initRoutesAdminUsers() {
|
|
7
|
+
return new adminUsersRoute();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default UsersAdminBootPlugin;
|
package/boot/plugins/api.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import BaseApiBootPlugin from '@thzero/library_server/boot/plugins/api';
|
|
2
|
-
|
|
3
|
-
import homeRoute from '../../routes/home';
|
|
4
|
-
import versionRoute from '../../routes/version';
|
|
5
|
-
|
|
6
|
-
class ApiBootPlugin extends BaseApiBootPlugin {
|
|
7
|
-
_initRoutesHome() {
|
|
8
|
-
return new homeRoute();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
_initRoutesVersion() {
|
|
12
|
-
return new versionRoute();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default ApiBootPlugin;
|
|
1
|
+
import BaseApiBootPlugin from '@thzero/library_server/boot/plugins/api';
|
|
2
|
+
|
|
3
|
+
import homeRoute from '../../routes/home';
|
|
4
|
+
import versionRoute from '../../routes/version';
|
|
5
|
+
|
|
6
|
+
class ApiBootPlugin extends BaseApiBootPlugin {
|
|
7
|
+
_initRoutesHome() {
|
|
8
|
+
return new homeRoute();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
_initRoutesVersion() {
|
|
12
|
+
return new versionRoute();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default ApiBootPlugin;
|
package/boot/plugins/apiFront.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import BaseApiFrontBootPlugin from '@thzero/library_server/boot/plugins/apiFront';
|
|
2
|
-
|
|
3
|
-
import utilityRoute from '../../routes/utility';
|
|
4
|
-
|
|
5
|
-
class FrontApiBootPlugin extends BaseApiFrontBootPlugin {
|
|
6
|
-
_initRoutesUtility() {
|
|
7
|
-
return new utilityRoute();
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default FrontApiBootPlugin;
|
|
1
|
+
import BaseApiFrontBootPlugin from '@thzero/library_server/boot/plugins/apiFront';
|
|
2
|
+
|
|
3
|
+
import utilityRoute from '../../routes/utility';
|
|
4
|
+
|
|
5
|
+
class FrontApiBootPlugin extends BaseApiFrontBootPlugin {
|
|
6
|
+
_initRoutesUtility() {
|
|
7
|
+
return new utilityRoute();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default FrontApiBootPlugin;
|
package/boot/plugins/news.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import BaseNewsApiBootPlugin from '@thzero/library_server/boot/plugins/news';
|
|
2
|
-
|
|
3
|
-
import newsRoute from '../../routes/news';
|
|
4
|
-
|
|
5
|
-
class NewsApiBootPlugin extends BaseNewsApiBootPlugin {
|
|
6
|
-
_initRoutesNews() {
|
|
7
|
-
return new newsRoute();
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default NewsApiBootPlugin;
|
|
1
|
+
import BaseNewsApiBootPlugin from '@thzero/library_server/boot/plugins/news';
|
|
2
|
+
|
|
3
|
+
import newsRoute from '../../routes/news';
|
|
4
|
+
|
|
5
|
+
class NewsApiBootPlugin extends BaseNewsApiBootPlugin {
|
|
6
|
+
_initRoutesNews() {
|
|
7
|
+
return new newsRoute();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default NewsApiBootPlugin;
|
package/boot/plugins/users.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import BaseUsersApiBootPlugin from '@thzero/library_server/boot/plugins/users';
|
|
2
|
-
|
|
3
|
-
import usersRoute from '../../routes/users';
|
|
4
|
-
|
|
5
|
-
class UsersApiBootPlugin extends BaseUsersApiBootPlugin {
|
|
6
|
-
_initRoutesUsers() {
|
|
7
|
-
return new usersRoute();
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default UsersApiBootPlugin;
|
|
1
|
+
import BaseUsersApiBootPlugin from '@thzero/library_server/boot/plugins/users';
|
|
2
|
+
|
|
3
|
+
import usersRoute from '../../routes/users';
|
|
4
|
+
|
|
5
|
+
class UsersApiBootPlugin extends BaseUsersApiBootPlugin {
|
|
6
|
+
_initRoutesUsers() {
|
|
7
|
+
return new usersRoute();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default UsersApiBootPlugin;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import BaseExtendedUsersApiBootPlugin from '@thzero/library_server/boot/plugins/usersExtended';
|
|
2
|
-
|
|
3
|
-
import plansService from '../../service/plans';
|
|
4
|
-
|
|
5
|
-
class ExtendedUsersApiBootPlugin extends BaseExtendedUsersApiBootPlugin {
|
|
6
|
-
_initServicesPlans() {
|
|
7
|
-
return new plansService();
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default ExtendedUsersApiBootPlugin;
|
|
1
|
+
import BaseExtendedUsersApiBootPlugin from '@thzero/library_server/boot/plugins/usersExtended';
|
|
2
|
+
|
|
3
|
+
import plansService from '../../service/plans';
|
|
4
|
+
|
|
5
|
+
class ExtendedUsersApiBootPlugin extends BaseExtendedUsersApiBootPlugin {
|
|
6
|
+
_initServicesPlans() {
|
|
7
|
+
return new plansService();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default ExtendedUsersApiBootPlugin;
|
package/license.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020-2026 thZero.com
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2026 thZero.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
9
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|