@nestim/koishi-plugin-qqgm-webui 0.2.13 → 0.2.14

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.
Files changed (2) hide show
  1. package/index.js +9 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -15,8 +15,15 @@ const { scan: scanMemoryMd, scopeOfFile } = require('./lib/memory-md');
15
15
  const run = promisify(execFile);
16
16
 
17
17
  async function readBody(koa) {
18
+ const parsed = koa.request && koa.request.body;
19
+ if (parsed && typeof parsed === 'object') return parsed;
20
+ if (typeof parsed === 'string' && parsed.trim()) {
21
+ try { return JSON.parse(parsed); } catch { return {}; }
22
+ }
18
23
  let raw = '';
19
- for await (const chunk of koa.req) raw += chunk;
24
+ try {
25
+ for await (const chunk of koa.req) raw += chunk;
26
+ } catch { /* body already consumed */ }
20
27
  if (!raw) return {};
21
28
  try { return JSON.parse(raw); } catch { return {}; }
22
29
  }
@@ -107,7 +114,7 @@ function apply(ctx, config) {
107
114
  ctx.server.get(`${route}/api/health`, (koa) => json(koa, {
108
115
  ok: true,
109
116
  name,
110
- version: '0.2.13',
117
+ version: '0.2.14',
111
118
  route,
112
119
  tokenRequired: !!config.token,
113
120
  remoteAllowed: !!config.allowRemote,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestim/koishi-plugin-qqgm-webui",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "QQGM 附属 WebUI:插件识别、监控看板、记忆库、配置与日志。",
5
5
  "main": "index.js",
6
6
  "files": [