befly 1.0.1 → 1.0.3

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
@@ -181,8 +181,7 @@ class BunPii {
181
181
  const fileName = path.basename(file, '.js');
182
182
  const apiPath = path.relative(apiDir, file).replace(/\.js$/, '').replace(/\\/g, '/');
183
183
  if (apiPath.indexOf('_') !== -1) continue;
184
- const api = await import(file);
185
- const apiInstance = api.default;
184
+ const api = (await import(file)).default;
186
185
  if (isType(api.name, 'string') === false || api.name.trim() === '') {
187
186
  throw new Error(`接口 ${apiPath} 的 name 属性必须是非空字符串`);
188
187
  }
@@ -202,8 +201,8 @@ class BunPii {
202
201
  if (isType(api.handler, 'function') === false) {
203
202
  throw new Error(`接口 ${apiPath} 的 handler 属性必须是函数`);
204
203
  }
205
- apiInstance.route = `${apiInstance.method.toUpperCase()}/api/${dirName}/${apiPath}`;
206
- this.apiRoutes.set(apiInstance.route, apiInstance);
204
+ api.route = `${api.method.toUpperCase()}/api/${dirName}/${apiPath}`;
205
+ this.apiRoutes.set(api.route, api);
207
206
  }
208
207
  } catch (error) {
209
208
  Logger.error({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Buma - 为 Bun 专属打造的 API 接口框架核心引擎",
5
5
  "type": "module",
6
6
  "private": false,
@@ -49,5 +49,5 @@
49
49
  "README.md",
50
50
  "vitest.config.js"
51
51
  ],
52
- "gitHead": "dc3350b08a8cd567188546b18db3465c7563f99e"
52
+ "gitHead": "3bd2e1f01b94f2b576467db1b63a016b6717dbbe"
53
53
  }
package/utils/util.js CHANGED
@@ -86,6 +86,8 @@ export const isType = (value, type) => {
86
86
  return value !== Object(value);
87
87
  case 'reference':
88
88
  return value === Object(value);
89
+ case 'function':
90
+ return typeof value === 'function';
89
91
  default:
90
92
  return actualType === expectedType;
91
93
  }