befly 3.17.7 → 3.17.8

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.
@@ -30,9 +30,7 @@ export class CacheHelper {
30
30
  const result = await this.redis.setObject(CacheKeys.apisAll(), apiList.data.lists);
31
31
 
32
32
  if (result === null) {
33
- throw new Error("接口缓存失败", {
34
- cause: null,
35
- code: "runtime",
33
+ Logger.warn("⚠️ 接口缓存失败", {
36
34
  subsystem: "cache",
37
35
  operation: "cacheApis"
38
36
  });
@@ -62,9 +60,7 @@ export class CacheHelper {
62
60
  const result = await this.redis.setObject(CacheKeys.menusAll(), menus.data.lists);
63
61
 
64
62
  if (result === null) {
65
- throw new Error("菜单缓存失败", {
66
- cause: null,
67
- code: "runtime",
63
+ Logger.warn("⚠️ 菜单缓存失败", {
68
64
  subsystem: "cache",
69
65
  operation: "cacheMenus"
70
66
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "3.17.7",
4
- "gitHead": "ca8aa895dc70ae26bf073f62ceba61c52076f066",
3
+ "version": "3.17.8",
4
+ "gitHead": "ff02e6df24881973a91e4943381ba8559ed9c55d",
5
5
  "private": false,
6
6
  "description": "Befly - 为 Bun 专属打造的 JavaScript API 接口框架核心引擎",
7
7
  "keywords": [
package/sync/cache.js CHANGED
@@ -1,13 +1,36 @@
1
1
  export async function syncCache(ctx) {
2
- // 1) 缓存接口列表
3
- await ctx.cache.cacheApis();
2
+ const tasks = [
3
+ { name: "cacheApis", run: () => ctx.cache.cacheApis() },
4
+ { name: "cacheMenus", run: () => ctx.cache.cacheMenus() },
5
+ { name: "cacheRoleApis", run: () => ctx.cache.cacheRoleApis() },
6
+ { name: "cacheRoleMenus", run: () => ctx.cache.cacheRoleMenus() }
7
+ ];
4
8
 
5
- // 2) 缓存菜单列表
6
- await ctx.cache.cacheMenus();
9
+ const failures = [];
7
10
 
8
- // 3) 重建角色权限缓存(严格模式下要求 role.apis 必须为 pathname 字符串数组)
9
- await ctx.cache.cacheRoleApis();
11
+ for (const task of tasks) {
12
+ try {
13
+ await task.run();
14
+ } catch (error) {
15
+ failures.push({
16
+ step: task.name,
17
+ message: String(error?.message || error),
18
+ error: error
19
+ });
20
+ }
21
+ }
10
22
 
11
- // 4) 重建角色菜单权限缓存(role.menus menu.path 字符串数组)
12
- await ctx.cache.cacheRoleMenus();
23
+ if (failures.length > 0) {
24
+ throw new Error("缓存同步失败", {
25
+ cause: failures[0].error,
26
+ code: "runtime",
27
+ subsystem: "sync",
28
+ operation: "syncCache",
29
+ failedSteps: failures.map((item) => item.step),
30
+ failures: failures.map((item) => ({
31
+ step: item.step,
32
+ message: item.message
33
+ }))
34
+ });
35
+ }
13
36
  }