befly 3.7.5 → 3.7.7
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/redisHelper.ts +3 -3
- package/package.json +2 -2
- package/router/api.ts +6 -0
package/lib/redisHelper.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const RedisHelper = {
|
|
|
44
44
|
const pkey = `${prefix}${key}`;
|
|
45
45
|
|
|
46
46
|
if (ttl) {
|
|
47
|
-
return await client.
|
|
47
|
+
return await client.setex(pkey, ttl, data);
|
|
48
48
|
}
|
|
49
49
|
return await client.set(pkey, data);
|
|
50
50
|
} catch (error: any) {
|
|
@@ -126,7 +126,7 @@ export const RedisHelper = {
|
|
|
126
126
|
const key = `${prefix}time_id_counter:${timestamp}`;
|
|
127
127
|
|
|
128
128
|
// 使用 INCRBY 一次性获取 N 个连续计数
|
|
129
|
-
const startCounter = await client.
|
|
129
|
+
const startCounter = await client.incrby(key, count);
|
|
130
130
|
await client.expire(key, 1);
|
|
131
131
|
|
|
132
132
|
// 生成 ID 数组
|
|
@@ -151,7 +151,7 @@ export const RedisHelper = {
|
|
|
151
151
|
const client = getClient();
|
|
152
152
|
const pkey = `${prefix}${key}`;
|
|
153
153
|
if (ttl) {
|
|
154
|
-
return await client.
|
|
154
|
+
return await client.setex(pkey, ttl, value);
|
|
155
155
|
}
|
|
156
156
|
return await client.set(pkey, value);
|
|
157
157
|
} catch (error: any) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.7",
|
|
4
4
|
"description": "Befly - 为 Bun 专属打造的 TypeScript API 接口框架核心引擎",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"es-toolkit": "^1.41.0",
|
|
70
70
|
"pathe": "^2.0.3"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "1716a6a3931dc231b8ac5a993b81e5de415bf596"
|
|
73
73
|
}
|
package/router/api.ts
CHANGED
|
@@ -99,6 +99,12 @@ export function apiHandler(apiRoutes: Map<string, ApiRoute>, pluginLists: Plugin
|
|
|
99
99
|
const result = await api.handler(appContext, ctx, req);
|
|
100
100
|
|
|
101
101
|
// 11. 返回响应
|
|
102
|
+
// 🔥 新增:直接返回 Response 对象
|
|
103
|
+
if (result instanceof Response) {
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 12. 返回响应
|
|
102
108
|
if (result && typeof result === 'object' && 'code' in result) {
|
|
103
109
|
// 处理 BigInt 序列化问题
|
|
104
110
|
const jsonString = JSON.stringify(result, (key, value) => (typeof value === 'bigint' ? value.toString() : value));
|