diff --git a/lib/AppLoader.d.ts b/lib/AppLoader.d.ts
index 56c471d..05370b0 100644
--- a/lib/AppLoader.d.ts
+++ b/lib/AppLoader.d.ts
@@ -1,10 +1,10 @@
+///
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { AppLoader as GeneralAppLoader, Trigger, EntityDict, Watcher, OpRecord, FreeTimer, OperationResult } from "oak-domain/lib/types";
import { DbStore } from "./DbStore";
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
import { IncomingHttpHeaders } from 'http';
import { Namespace } from 'socket.io';
-import Koa from "koa";
import DataSubscriber from './cluster/DataSubscriber';
import Synchronizer from './Synchronizer';
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
diff --git a/lib/AppLoader.js b/lib/AppLoader.js
index 7f893fb..ecd5bb1 100644
--- a/lib/AppLoader.js
+++ b/lib/AppLoader.js
@@ -274,42 +274,25 @@ class AppLoader extends types_1.AppLoader {
url += `/:${p}`;
}
}
- if (type == "custom") {
- endPointRouters.push([type, name, method, url, async (koaCtx) => {
- const { request, res } = koaCtx;
- const { headers } = request;
- koaCtx.respond = false;
- try {
- await fn(() => this.makeContext(undefined, headers), koaCtx);
- res.statusCode = 200;
- }
- catch (err) {
- console.error(`endpoint「${key}」方法「${method}」出错`, err);
- res.statusCode = 500;
- throw err;
- }
- finally {
- res.end();
- }
- }]);
- }
- else {
- endPointRouters.push([type, name, method, url, async (koaCtx) => {
- const { request, params } = koaCtx;
- const { body, headers, files, req } = request;
+ endPointRouters.push([name, method, url, async (params, headers, req, body) => {
+ let result;
+ if (type == "custom") {
+ result = await fn(() => this.makeContext(undefined, headers), params, headers, req, body);
+ }
+ else {
const context = await this.makeContext(undefined, headers);
try {
- const result = await fn(context, params, headers, req, files ? Object.assign({}, body, files) : body);
+ result = await fn(context, params, headers, req, body);
await context.commit();
- request.body = result;
}
catch (err) {
await context.rollback();
console.error(`endpoint「${key}」方法「${method}」出错`, err);
throw err;
}
- }]);
- }
+ }
+ return result;
+ }]);
};
if (endPointMap[k]) {
if (process.env.NODE_ENV === 'development') {
diff --git a/lib/Synchronizer.d.ts b/lib/Synchronizer.d.ts
index eca40d7..2283d42 100644
--- a/lib/Synchronizer.d.ts
+++ b/lib/Synchronizer.d.ts
@@ -27,7 +27,7 @@ export default class Synchronizer>;
+ getSyncTriggers(): VolatileTrigger[];
getSelfEndpoint(): EndpointItem;
tryCreateSyncProcess(): void;
}
diff --git a/lib/Synchronizer.js b/lib/Synchronizer.js
index 066a5a7..4e7aa92 100644
--- a/lib/Synchronizer.js
+++ b/lib/Synchronizer.js
@@ -114,7 +114,7 @@ class Synchronizer {
remoteEntityId: entityId,
data: queue.map((ele) => ({
entity: ele.oper.targetEntity,
- rowIds: ele.oper.filter.id.$in, // 暂时应该没什么用
+ rowIds: ele.oper.filter.id.$in,
action: ele.oper.action,
data: ele.oper.data,
})),
diff --git a/lib/cluster/env.js b/lib/cluster/env.js
index 7503829..63fef08 100644
--- a/lib/cluster/env.js
+++ b/lib/cluster/env.js
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.getClusterInfo = getClusterInfo;
+exports.getClusterInfo = void 0;
function getProcessEnvOption(option) {
if (process.env.hasOwnProperty(option)) {
return process.env[option];
@@ -54,3 +54,4 @@ const MyClusterInfo = initialize();
function getClusterInfo() {
return MyClusterInfo;
}
+exports.getClusterInfo = getClusterInfo;
diff --git a/src/AppLoader.ts b/src/AppLoader.ts
index e55e93d..ab4dc49 100644
--- a/src/AppLoader.ts
+++ b/src/AppLoader.ts
@@ -342,45 +342,28 @@ export class AppLoader {
- const { request, res } = koaCtx
- const { headers } = request;
- koaCtx.respond = false
- try {
- await fn(() => this.makeContext(undefined, headers), koaCtx);
- res.statusCode = 200
- }
- catch (err) {
- console.error(`endpoint「${key}」方法「${method}」出错`, err);
- res.statusCode = 500
- throw err;
- } finally {
- res.end()
- }
- }]
- );
- } else {
- endPointRouters.push(
- [type, name, method, url, async (koaCtx) => {
- const { response, request, params } = koaCtx;
- const { body, headers, files, req } = request;
- const context = await this.makeContext(undefined, headers);
+ endPointRouters.push(
+ [name, method, url, async (params, headers, req, body) => {
+ let result: string | NodeJS.ReadableStream
+ if (type == "custom") {
+ result = await fn(() => this.makeContext(undefined, headers), params, headers, req, body);
+ } else {
+ const context = await this.makeContext(undefined, headers);
try {
- const result = await fn(context, params, headers, req, files ? Object.assign({}, body, files) : body);
+ result = await fn(context, params, headers, req, body);
await context.commit();
- response.body = result;
}
catch (err) {
await context.rollback();
console.error(`endpoint「${key}」方法「${method}」出错`, err);
throw err;
}
- }]
- );
- }
+ }
+ return result;
+
+ }]
+ );
}
if (endPointMap[k]) {
if (process.env.NODE_ENV === 'development') {