befly 2.3.0 → 2.3.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/main.js CHANGED
@@ -43,11 +43,20 @@ class Befly {
43
43
  const singleCheckStart = Bun.nanoseconds();
44
44
 
45
45
  // 导入检查模块
46
- const check = await import(file);
46
+ const checkModule = await import(file);
47
+
48
+ // 仅允许具名导出(以 check 开头)的检查函数
49
+ let checkFn = null;
50
+ for (const [exportName, exportValue] of Object.entries(checkModule)) {
51
+ if (typeof exportValue === 'function' && /^check/i.test(exportName)) {
52
+ checkFn = exportValue;
53
+ break;
54
+ }
55
+ }
47
56
 
48
- // 执行默认导出的函数
49
- if (typeof check.default === 'function') {
50
- const checkResult = await check.default(this.appContext);
57
+ // 执行检查函数
58
+ if (typeof checkFn === 'function') {
59
+ const checkResult = await checkFn(this.appContext);
51
60
  const singleCheckTime = calcPerfTime(singleCheckStart);
52
61
 
53
62
  if (checkResult === true) {
@@ -59,7 +68,7 @@ class Befly {
59
68
  }
60
69
  } else {
61
70
  const singleCheckTime = calcPerfTime(singleCheckStart);
62
- Logger.warn(`文件 ${fileName} 未导出默认函数,耗时: ${singleCheckTime}`);
71
+ Logger.warn(`文件 ${fileName} 未找到可执行的检查函数(必须具名导出以 check 开头的函数),耗时: ${singleCheckTime}`);
63
72
  failedChecks++;
64
73
  }
65
74
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Buma - 为 Bun 专属打造的 API 接口框架核心引擎",
5
5
  "type": "module",
6
6
  "private": false,
package/utils/index.js CHANGED
@@ -93,6 +93,9 @@ export const isType = (value, type) => {
93
93
 
94
94
  // 语义类型单独处理,其余走 actualType === expectedType
95
95
  switch (expectedType) {
96
+ case 'function':
97
+ // 统一将普通函数、异步函数、生成器函数等都识别为函数
98
+ return typeof value === 'function';
96
99
  case 'nan':
97
100
  return typeof value === 'number' && Number.isNaN(value);
98
101
  case 'empty':