alemonjs 2.1.0-alpha.34 → 2.1.0-alpha.36
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/lib/cbp/router.js +10 -5
- package/lib/cbp/testone.js +0 -16
- package/package.json +1 -1
package/lib/cbp/router.js
CHANGED
|
@@ -102,7 +102,7 @@ router.all('app/{*path}', async (ctx) => {
|
|
|
102
102
|
};
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
const apiModule = await import(modulePath);
|
|
105
|
+
const apiModule = await import(`file://${modulePath}`);
|
|
106
106
|
if (!apiModule[ctx.method] || typeof apiModule[ctx.method] !== 'function') {
|
|
107
107
|
ctx.status = 405;
|
|
108
108
|
return;
|
|
@@ -140,7 +140,9 @@ router.all('app/{*path}', async (ctx) => {
|
|
|
140
140
|
};
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
const fullPath = root
|
|
143
|
+
const fullPath = root
|
|
144
|
+
? path.join(rootPath, root, resourcePath)
|
|
145
|
+
: path.join(rootPath, resourcePath);
|
|
144
146
|
try {
|
|
145
147
|
// 返回文件
|
|
146
148
|
const file = await fs.promises.readFile(fullPath);
|
|
@@ -214,7 +216,7 @@ router.all('apps/:app/{*path}', async (ctx) => {
|
|
|
214
216
|
};
|
|
215
217
|
return;
|
|
216
218
|
}
|
|
217
|
-
const apiModule = await import(modulePath);
|
|
219
|
+
const apiModule = await import(`file://${modulePath}`);
|
|
218
220
|
if (!apiModule[ctx.method] || typeof apiModule[ctx.method] !== 'function') {
|
|
219
221
|
ctx.status = 405;
|
|
220
222
|
return;
|
|
@@ -237,7 +239,8 @@ router.all('apps/:app/{*path}', async (ctx) => {
|
|
|
237
239
|
ctx.status = 405;
|
|
238
240
|
return;
|
|
239
241
|
}
|
|
240
|
-
|
|
242
|
+
// 不是 packages,而是 node_modules。需要是模块化
|
|
243
|
+
const rootPath = path.join(process.cwd(), 'node_modules', appName);
|
|
241
244
|
const resourcePath = formatPath(ctx.params?.path);
|
|
242
245
|
let root = '';
|
|
243
246
|
try {
|
|
@@ -253,7 +256,9 @@ router.all('apps/:app/{*path}', async (ctx) => {
|
|
|
253
256
|
};
|
|
254
257
|
return;
|
|
255
258
|
}
|
|
256
|
-
const fullPath = root
|
|
259
|
+
const fullPath = root
|
|
260
|
+
? path.join(rootPath, root, resourcePath)
|
|
261
|
+
: path.join(rootPath, resourcePath);
|
|
257
262
|
try {
|
|
258
263
|
// 返回文件
|
|
259
264
|
const file = await fs.promises.readFile(fullPath);
|
package/lib/cbp/testone.js
CHANGED
|
@@ -5,24 +5,8 @@ import { existsSync, mkdirSync, watch, readFileSync, writeFile } from 'fs';
|
|
|
5
5
|
import _ from 'lodash';
|
|
6
6
|
import { readFile } from 'fs/promises';
|
|
7
7
|
import { actionResolves, actionTimeouts, apiResolves, apiTimeouts } from './config.js';
|
|
8
|
-
import '../app/define-chidren.js';
|
|
9
|
-
import '../app/event-group.js';
|
|
10
|
-
import '../app/event-middleware.js';
|
|
11
|
-
import '../app/event-response.js';
|
|
12
|
-
import '../app/hook-use-api.js';
|
|
13
|
-
import '../typing/event/actions.js';
|
|
14
|
-
import 'yaml';
|
|
15
8
|
import { ResultCode } from '../core/code.js';
|
|
16
|
-
import 'node:fs';
|
|
17
|
-
import 'log4js';
|
|
18
|
-
import '../app/load.js';
|
|
19
|
-
import '../app/message-api.js';
|
|
20
|
-
import '../app/message-format.js';
|
|
21
9
|
import { createResult } from '../core/utils.js';
|
|
22
|
-
import 'ws';
|
|
23
|
-
import 'koa';
|
|
24
|
-
import './router.js';
|
|
25
|
-
import '@koa/cors';
|
|
26
10
|
|
|
27
11
|
/**
|
|
28
12
|
* @param ws
|