kb-server 0.0.3 → 0.0.5

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.
@@ -12,7 +12,7 @@ function createAPI(ParamsClass, execution) {
12
12
  // 校验参数
13
13
  const paramsToCheck = params instanceof ParamsClass
14
14
  ? params
15
- : (0, class_transformer_1.plainToClass)(ParamsClass, params);
15
+ : (0, class_transformer_1.plainToInstance)(ParamsClass, params);
16
16
  const errors = await (0, class_validator_1.validate)(paramsToCheck || {});
17
17
  if (errors?.length) {
18
18
  const errorMessages = errors.flatMap((error) => getMessage(error));
@@ -119,7 +119,15 @@ const packSSE = (sseHandlers, options) => {
119
119
  const response = (0, exports.createSSEMsg)("done", "[DONE]");
120
120
  res.write(response, () => res.end());
121
121
  };
122
- await execution(params, { push, close, abortController }, ctx);
122
+ try {
123
+ await execution(params, { push, close, abortController }, ctx);
124
+ }
125
+ catch (error) {
126
+ // 业务内部的 abort 不关注
127
+ if (error?.name === "AbortError")
128
+ return;
129
+ throw error;
130
+ }
123
131
  }
124
132
  catch (rawError) {
125
133
  logger_1.logger.error(rawError);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kb-server",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "A fast server for Node.JS,made by express.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {