@grandlinex/kernel 0.28.0 → 0.28.1
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/dist/KernelModule.js
CHANGED
|
@@ -23,11 +23,11 @@ class KernelModule extends BaseKernelModule_1.default {
|
|
|
23
23
|
super('base-mod', kernel);
|
|
24
24
|
this.addAction(new ApiVersionAction_1.default(this), new ApiAuthTestAction_1.default(this), new GetTokenAction_1.default(this));
|
|
25
25
|
this.addService(new core_1.OfflineService(this));
|
|
26
|
+
const endpoint = new KernelEndpoint_1.default('api', this, this.getKernel().getAppServerPort());
|
|
27
|
+
this.setPresenter(endpoint);
|
|
26
28
|
}
|
|
27
29
|
initModule() {
|
|
28
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const endpoint = new KernelEndpoint_1.default('api', this, this.getKernel().getAppServerPort());
|
|
30
|
-
this.setPresenter(endpoint);
|
|
31
31
|
yield this.getKernel().triggerFunction('load');
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import express from 'express';
|
|
3
|
+
import express, { Express } from 'express';
|
|
4
4
|
import http from 'http';
|
|
5
5
|
import { CorePresenter, IDataBase } from '@grandlinex/core';
|
|
6
6
|
import { IBaseCache, IBaseClient, IBaseKernelModule, IBasePresenter, IKernel } from '../lib';
|
|
@@ -11,6 +11,7 @@ export default abstract class BaseEndpoint<K extends IKernel = IKernel, T extend
|
|
|
11
11
|
protected httpServer: http.Server;
|
|
12
12
|
protected port: number;
|
|
13
13
|
constructor(chanel: string, module: IBaseKernelModule<any, any, any, any>, port: number);
|
|
14
|
+
appServerOverride(app: Express): void;
|
|
14
15
|
start(): Promise<boolean>;
|
|
15
16
|
stop(): Promise<boolean>;
|
|
16
17
|
getApp(): express.Express;
|
|
@@ -9,7 +9,10 @@ const http_1 = __importDefault(require("http"));
|
|
|
9
9
|
const body_parser_1 = require("body-parser");
|
|
10
10
|
const core_1 = require("@grandlinex/core");
|
|
11
11
|
function keepRawBody(req, res, buf, encoding) {
|
|
12
|
-
|
|
12
|
+
var _a;
|
|
13
|
+
if (((_a = req.headers['content-type']) === null || _a === void 0 ? void 0 : _a.startsWith('application/json')) &&
|
|
14
|
+
buf &&
|
|
15
|
+
buf.length) {
|
|
13
16
|
try {
|
|
14
17
|
req.rawBody = buf.toString(encoding || 'utf8');
|
|
15
18
|
}
|
|
@@ -27,6 +30,10 @@ class BaseEndpoint extends core_1.CorePresenter {
|
|
|
27
30
|
this.appServer.use((0, body_parser_1.json)({ verify: keepRawBody }));
|
|
28
31
|
this.httpServer = http_1.default.createServer(this.appServer);
|
|
29
32
|
}
|
|
33
|
+
appServerOverride(app) {
|
|
34
|
+
this.appServer = app;
|
|
35
|
+
this.httpServer = http_1.default.createServer(this.appServer);
|
|
36
|
+
}
|
|
30
37
|
start() {
|
|
31
38
|
return new Promise((resolve) => {
|
|
32
39
|
this.httpServer
|