befly 1.2.4 → 1.2.6

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/main.js +3 -3
  2. package/package.json +2 -2
package/main.js CHANGED
@@ -255,8 +255,8 @@ class Befly {
255
255
  if (isType(api.name, 'string') === false || api.name.trim() === '') {
256
256
  throw new Error(`接口 ${apiPath} 的 name 属性必须是非空字符串`);
257
257
  }
258
- if (api.auth !== false && api.auth !== true && Array.isArray(api.auth) === false) {
259
- throw new Error(`接口 ${apiPath} 的 auth 属性必须是布尔值或字符串数组`);
258
+ if (isType(api.auth, 'boolean') === false && isType(api.auth, 'array') === false && isType(api.auth, 'string') === false) {
259
+ throw new Error(`接口 ${apiPath} 的 auth 属性必须是布尔值或字符串或字符串数组`);
260
260
  }
261
261
  if (isType(api.fields, 'object') === false) {
262
262
  throw new Error(`接口 ${apiPath} 的 fields 属性必须是对象`);
@@ -446,7 +446,7 @@ class Befly {
446
446
 
447
447
  // 登录验证 auth 有3种值 分别为 true、false、['admin', 'user']
448
448
  if (api.auth === true && !ctx.user.id) {
449
- return Response.json(RNo('未登录'), {
449
+ return Response.json(RNo('未登录', {}, { login: false }), {
450
450
  headers: corsOptions.headers
451
451
  });
452
452
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
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": "2615f45da0551949dee6f75123c54259b91c05ef"
52
+ "gitHead": "61da14584fbbff2c933b481ef69681240bc4ac27"
53
53
  }