befly 3.8.14 → 3.8.16
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/env.ts +1 -2
- package/package.json +2 -2
- package/plugins/db.ts +2 -2
- package/plugins/redis.ts +1 -1
- package/types/env.ts +1 -2
package/env.ts
CHANGED
|
@@ -33,7 +33,7 @@ const coreEnv: EnvConfig = {
|
|
|
33
33
|
LOG_MAX_SIZE: 10 * 1024 * 1024, // 10MB
|
|
34
34
|
|
|
35
35
|
// ========== 数据库配置 ==========
|
|
36
|
-
|
|
36
|
+
DATABASE_ENABLE: 0,
|
|
37
37
|
DB_TYPE: 'mysql',
|
|
38
38
|
DB_HOST: '127.0.0.1',
|
|
39
39
|
DB_PORT: 3306,
|
|
@@ -43,7 +43,6 @@ const coreEnv: EnvConfig = {
|
|
|
43
43
|
DB_POOL_MAX: 10,
|
|
44
44
|
|
|
45
45
|
// ========== Redis 配置 ==========
|
|
46
|
-
REDIS_ENABLE: 0,
|
|
47
46
|
REDIS_HOST: '127.0.0.1',
|
|
48
47
|
REDIS_PORT: 6379,
|
|
49
48
|
REDIS_USERNAME: '',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.16",
|
|
4
4
|
"description": "Befly - 为 Bun 专属打造的 TypeScript API 接口框架核心引擎",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"es-toolkit": "^1.41.0",
|
|
66
66
|
"pathe": "^2.0.3"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "e6af0b2f2d9ac2b7200e7f9f7e7dd5c407bddf30"
|
|
69
69
|
}
|
package/plugins/db.ts
CHANGED
|
@@ -21,7 +21,7 @@ const dbPlugin: Plugin = {
|
|
|
21
21
|
let sql: any = null;
|
|
22
22
|
|
|
23
23
|
try {
|
|
24
|
-
if (Env.
|
|
24
|
+
if (Env.DATABASE_ENABLE === 1) {
|
|
25
25
|
// 创建 Bun SQL 客户端(内置连接池),并确保连接验证成功后再继续
|
|
26
26
|
// 从环境变量读取连接超时配置
|
|
27
27
|
const connectionTimeout = Env.DB_CONNECTION_TIMEOUT ? parseInt(Env.DB_CONNECTION_TIMEOUT) : 30000;
|
|
@@ -35,7 +35,7 @@ const dbPlugin: Plugin = {
|
|
|
35
35
|
|
|
36
36
|
return dbManager;
|
|
37
37
|
} else {
|
|
38
|
-
Logger.warn('
|
|
38
|
+
Logger.warn('数据库未启用,跳过初始化');
|
|
39
39
|
return {};
|
|
40
40
|
}
|
|
41
41
|
} catch (error: any) {
|
package/plugins/redis.ts
CHANGED
|
@@ -19,7 +19,7 @@ const redisPlugin: Plugin = {
|
|
|
19
19
|
|
|
20
20
|
async onInit(befly: BeflyContext): Promise<RedisHelper | Record<string, never>> {
|
|
21
21
|
try {
|
|
22
|
-
if (Env.
|
|
22
|
+
if (Env.DATABASE_ENABLE === 1) {
|
|
23
23
|
// 初始化 Redis 客户端(统一使用 database.ts 的连接管理)
|
|
24
24
|
await Database.connectRedis();
|
|
25
25
|
|
package/types/env.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface EnvConfig {
|
|
|
23
23
|
TZ: string;
|
|
24
24
|
|
|
25
25
|
// ========== 数据库配置 ==========
|
|
26
|
-
|
|
26
|
+
DATABASE_ENABLE: number;
|
|
27
27
|
DB_TYPE: string;
|
|
28
28
|
DB_HOST: string;
|
|
29
29
|
DB_PORT: number;
|
|
@@ -33,7 +33,6 @@ export interface EnvConfig {
|
|
|
33
33
|
DB_POOL_MAX: number;
|
|
34
34
|
|
|
35
35
|
// ========== Redis 配置 ==========
|
|
36
|
-
REDIS_ENABLE: number;
|
|
37
36
|
REDIS_HOST: string;
|
|
38
37
|
REDIS_PORT: number;
|
|
39
38
|
REDIS_USERNAME: string;
|