befly 3.10.19 → 3.11.1

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 (125) hide show
  1. package/dist/befly.config.d.ts +1 -1
  2. package/dist/befly.config.js +3 -5
  3. package/dist/befly.js +15621 -0
  4. package/dist/befly.min.js +21 -0
  5. package/dist/checks/checkApi.js +2 -3
  6. package/dist/checks/checkHook.js +50 -3
  7. package/dist/checks/checkMenu.d.ts +2 -2
  8. package/dist/checks/checkMenu.js +3 -3
  9. package/dist/checks/checkPlugin.js +50 -3
  10. package/dist/checks/checkTable.d.ts +1 -1
  11. package/dist/checks/checkTable.js +1 -1
  12. package/dist/hooks/auth.d.ts +3 -1
  13. package/dist/hooks/auth.js +3 -1
  14. package/dist/hooks/cors.d.ts +3 -1
  15. package/dist/hooks/cors.js +3 -1
  16. package/dist/hooks/parser.d.ts +3 -1
  17. package/dist/hooks/parser.js +4 -3
  18. package/dist/hooks/permission.d.ts +3 -1
  19. package/dist/hooks/permission.js +5 -3
  20. package/dist/hooks/validator.d.ts +3 -1
  21. package/dist/hooks/validator.js +4 -2
  22. package/dist/{main.d.ts → index.d.ts} +1 -1
  23. package/dist/{main.js → index.js} +24 -24
  24. package/dist/lib/cacheHelper.js +2 -2
  25. package/dist/lib/cipher.d.ts +1 -1
  26. package/dist/lib/connect.d.ts +1 -1
  27. package/dist/lib/connect.js +1 -1
  28. package/dist/lib/dbHelper.d.ts +3 -3
  29. package/dist/lib/dbHelper.js +9 -11
  30. package/dist/lib/dbUtils.d.ts +1 -1
  31. package/dist/lib/dbUtils.js +2 -3
  32. package/dist/lib/jwt.d.ts +2 -2
  33. package/dist/lib/logger.d.ts +17 -7
  34. package/dist/lib/logger.js +620 -210
  35. package/dist/lib/redisHelper.js +2 -2
  36. package/dist/lib/sqlBuilder.d.ts +1 -1
  37. package/dist/lib/sqlBuilder.js +1 -1
  38. package/dist/lib/validator.d.ts +1 -1
  39. package/dist/lib/validator.js +1 -1
  40. package/dist/loader/loadApis.d.ts +2 -2
  41. package/dist/loader/loadApis.js +3 -3
  42. package/dist/loader/loadHooks.d.ts +3 -4
  43. package/dist/loader/loadHooks.js +6 -8
  44. package/dist/loader/loadPlugins.d.ts +4 -4
  45. package/dist/loader/loadPlugins.js +7 -7
  46. package/dist/plugins/cache.d.ts +4 -2
  47. package/dist/plugins/cache.js +3 -1
  48. package/dist/plugins/cipher.d.ts +3 -1
  49. package/dist/plugins/cipher.js +3 -1
  50. package/dist/plugins/config.d.ts +4 -2
  51. package/dist/plugins/config.js +2 -0
  52. package/dist/plugins/db.d.ts +4 -2
  53. package/dist/plugins/db.js +6 -4
  54. package/dist/plugins/jwt.d.ts +4 -2
  55. package/dist/plugins/jwt.js +3 -1
  56. package/dist/plugins/logger.d.ts +7 -3
  57. package/dist/plugins/logger.js +3 -1
  58. package/dist/plugins/redis.d.ts +4 -2
  59. package/dist/plugins/redis.js +5 -3
  60. package/dist/plugins/tool.d.ts +3 -1
  61. package/dist/plugins/tool.js +2 -0
  62. package/dist/router/api.d.ts +3 -3
  63. package/dist/router/api.js +5 -5
  64. package/dist/router/static.d.ts +1 -1
  65. package/dist/router/static.js +3 -3
  66. package/dist/scripts/ensureDist.js +218 -2
  67. package/dist/sync/syncApi.d.ts +2 -2
  68. package/dist/sync/syncApi.js +2 -2
  69. package/dist/sync/syncCache.d.ts +1 -1
  70. package/dist/sync/syncDev.d.ts +1 -1
  71. package/dist/sync/syncDev.js +2 -2
  72. package/dist/sync/syncMenu.d.ts +2 -2
  73. package/dist/sync/syncMenu.js +4 -4
  74. package/dist/sync/syncTable.d.ts +6 -6
  75. package/dist/sync/syncTable.js +4 -4
  76. package/dist/types/api.d.ts +4 -4
  77. package/dist/types/befly.d.ts +8 -12
  78. package/dist/types/cache.d.ts +2 -2
  79. package/dist/types/cipher.d.ts +1 -1
  80. package/dist/types/context.d.ts +1 -1
  81. package/dist/types/database.d.ts +1 -1
  82. package/dist/types/hook.d.ts +4 -2
  83. package/dist/types/logger.d.ts +14 -2
  84. package/dist/types/plugin.d.ts +3 -1
  85. package/dist/types/sync.d.ts +2 -2
  86. package/dist/utils/cors.d.ts +1 -1
  87. package/dist/utils/importDefault.js +1 -1
  88. package/dist/utils/loadMenuConfigs.d.ts +26 -2
  89. package/dist/utils/loadMenuConfigs.js +44 -3
  90. package/dist/utils/mergeAndConcat.d.ts +7 -0
  91. package/dist/utils/mergeAndConcat.js +72 -0
  92. package/dist/utils/processAtSymbol.d.ts +4 -0
  93. package/dist/utils/{processFields.js → processAtSymbol.js} +2 -2
  94. package/dist/utils/response.d.ts +1 -1
  95. package/dist/utils/response.js +1 -1
  96. package/dist/utils/scanAddons.js +3 -3
  97. package/dist/utils/scanConfig.js +6 -7
  98. package/dist/utils/scanCoreBuiltins.d.ts +3 -0
  99. package/dist/utils/scanCoreBuiltins.js +65 -0
  100. package/dist/utils/scanFiles.js +19 -6
  101. package/dist/utils/scanSources.d.ts +2 -2
  102. package/dist/utils/scanSources.js +16 -11
  103. package/dist/utils/sortModules.js +2 -2
  104. package/dist/utils/util.d.ts +84 -0
  105. package/dist/utils/util.js +262 -0
  106. package/package.json +20 -14
  107. package/dist/utils/arrayKeysToCamel.d.ts +0 -13
  108. package/dist/utils/arrayKeysToCamel.js +0 -18
  109. package/dist/utils/configTypes.d.ts +0 -1
  110. package/dist/utils/configTypes.js +0 -1
  111. package/dist/utils/genShortId.d.ts +0 -10
  112. package/dist/utils/genShortId.js +0 -12
  113. package/dist/utils/keysToCamel.d.ts +0 -10
  114. package/dist/utils/keysToCamel.js +0 -21
  115. package/dist/utils/keysToSnake.d.ts +0 -10
  116. package/dist/utils/keysToSnake.js +0 -21
  117. package/dist/utils/pickFields.d.ts +0 -4
  118. package/dist/utils/pickFields.js +0 -16
  119. package/dist/utils/processFields.d.ts +0 -4
  120. package/dist/utils/regex.d.ts +0 -145
  121. package/dist/utils/regex.js +0 -202
  122. package/dist/utils/sqlLog.d.ts +0 -14
  123. package/dist/utils/sqlLog.js +0 -25
  124. /package/dist/utils/{process.d.ts → processInfo.d.ts} +0 -0
  125. /package/dist/utils/{process.js → processInfo.js} +0 -0
@@ -2,8 +2,8 @@
2
2
  * Redis 助手 - TypeScript 版本
3
3
  * 提供 Redis 操作的便捷方法
4
4
  */
5
- import { Connect } from "./connect.js";
6
- import { Logger } from "./logger.js";
5
+ import { Connect } from "./connect";
6
+ import { Logger } from "./logger";
7
7
  /**
8
8
  * Redis 助手类
9
9
  * 约定:除构造函数外,方法默认不抛异常;失败时返回 null/false/0/[] 并记录日志。
@@ -2,7 +2,7 @@
2
2
  * SQL 构造器 - TypeScript 版本
3
3
  * 提供链式 API 构建 SQL 查询
4
4
  */
5
- import type { WhereConditions, SqlQuery, InsertData, UpdateData, SqlValue } from "../types/common.ts";
5
+ import type { WhereConditions, SqlQuery, InsertData, UpdateData, SqlValue } from "../types/common";
6
6
  /**
7
7
  * SQL 构建器类
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * SQL 构造器 - TypeScript 版本
3
3
  * 提供链式 API 构建 SQL 查询
4
4
  */
5
- import { SqlCheck } from "./sqlCheck.js";
5
+ import { SqlCheck } from "./sqlCheck";
6
6
  const SqlBuilderError = {
7
7
  QUOTE_IDENT_NEED_STRING: (identifier) => `quoteIdent 需要字符串类型标识符 (identifier: ${String(identifier)})`,
8
8
  IDENT_EMPTY: "SQL 标识符不能为空",
@@ -2,7 +2,7 @@
2
2
  * 数据验证器 - Befly 项目专用
3
3
  * 纯静态类设计,简洁易用
4
4
  */
5
- import type { TableDefinition, FieldDefinition, ValidateResult, SingleResult } from "../types/validate.ts";
5
+ import type { TableDefinition, FieldDefinition, ValidateResult, SingleResult } from "../types/validate";
6
6
  /**
7
7
  * 验证器类
8
8
  *
@@ -2,7 +2,7 @@
2
2
  * 数据验证器 - Befly 项目专用
3
3
  * 纯静态类设计,简洁易用
4
4
  */
5
- import { RegexAliases, getCompiledRegex } from "../configs/presetRegexp.js";
5
+ import { RegexAliases, getCompiledRegex } from "../configs/presetRegexp";
6
6
  /**
7
7
  * 验证器类
8
8
  *
@@ -2,8 +2,8 @@
2
2
  * API 加载器
3
3
  * 负责扫描和加载所有 API 路由(组件、项目)
4
4
  */
5
- import type { ApiRoute } from "../types/api.ts";
6
- import type { ScanFileResult } from "../utils/scanFiles.ts";
5
+ import type { ApiRoute } from "../types/api";
6
+ import type { ScanFileResult } from "../utils/scanFiles";
7
7
  /**
8
8
  * 加载所有 API 路由
9
9
  * @param apiItems - scanSources/scanFiles 扫描到的 API 条目数组
@@ -2,8 +2,8 @@
2
2
  * API 加载器
3
3
  * 负责扫描和加载所有 API 路由(组件、项目)
4
4
  */
5
- import { Logger } from "../lib/logger.js";
6
- import { processFields } from "../utils/processFields.js";
5
+ import { Logger } from "../lib/logger";
6
+ import { processAtSymbol } from "../utils/processAtSymbol";
7
7
  /**
8
8
  * 加载所有 API 路由
9
9
  * @param apiItems - scanSources/scanFiles 扫描到的 API 条目数组
@@ -21,7 +21,7 @@ export async function loadApis(apis) {
21
21
  try {
22
22
  const apiRoute = api;
23
23
  // 处理字段定义,将 @ 引用替换为实际字段定义
24
- apiRoute.fields = processFields(apiRoute.fields || {}, apiRoute.name, apiRoute.routePath);
24
+ apiRoute.fields = processAtSymbol(apiRoute.fields || {}, apiRoute.name, apiRoute.routePath);
25
25
  apisMap.set(apiRoute.routePath, apiRoute);
26
26
  }
27
27
  catch (error) {
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * 钩子加载器
3
3
  * 默认加载所有来源钩子(core/addon/app)
4
- * 可通过 disableHooks 禁用指定钩子
5
4
  */
6
- import type { Hook } from "../types/hook.ts";
7
- import type { ScanFileResult } from "../utils/scanFiles.ts";
8
- export declare function loadHooks(hooks: ScanFileResult[], disableHooks?: string[]): Promise<Hook[]>;
5
+ import type { Hook } from "../types/hook";
6
+ import type { ScanFileResult } from "../utils/scanFiles";
7
+ export declare function loadHooks(hooks: ScanFileResult[]): Promise<Hook[]>;
@@ -1,21 +1,18 @@
1
1
  /**
2
2
  * 钩子加载器
3
3
  * 默认加载所有来源钩子(core/addon/app)
4
- * 可通过 disableHooks 禁用指定钩子
5
4
  */
6
- import { Logger } from "../lib/logger.js";
7
- import { sortModules } from "../utils/sortModules.js";
8
- export async function loadHooks(hooks, disableHooks = []) {
5
+ import { sortModules } from "../utils/sortModules";
6
+ export async function loadHooks(hooks) {
9
7
  const hooksMap = [];
10
- if (disableHooks.length > 0) {
11
- Logger.info({ hooks: disableHooks }, "禁用钩子");
12
- }
13
8
  const enabledHooks = hooks.filter((item) => {
14
9
  const moduleName = item?.moduleName;
15
10
  if (typeof moduleName !== "string" || moduleName.trim() === "") {
16
11
  return false;
17
12
  }
18
- if (disableHooks.includes(moduleName)) {
13
+ // enable=false 表示禁用(替代 disableHooks 列表)。
14
+ // enable 仅允许 boolean;缺失 enable 的默认值应在 checkHook 阶段被补全为 true。
15
+ if (item?.enable === false) {
19
16
  return false;
20
17
  }
21
18
  return true;
@@ -29,6 +26,7 @@ export async function loadHooks(hooks, disableHooks = []) {
29
26
  const hook = item;
30
27
  hooksMap.push({
31
28
  name: hookName,
29
+ enable: true,
32
30
  deps: hook.deps,
33
31
  handler: hook.handler
34
32
  });
@@ -2,7 +2,7 @@
2
2
  * 插件加载器
3
3
  * 负责扫描和初始化所有插件(核心、组件、项目)
4
4
  */
5
- import type { BeflyContext } from "../types/befly.ts";
6
- import type { Plugin } from "../types/plugin.ts";
7
- import type { ScanFileResult } from "../utils/scanFiles.ts";
8
- export declare function loadPlugins(plugins: ScanFileResult[], context: BeflyContext, disablePlugins?: string[]): Promise<Plugin[]>;
5
+ import type { BeflyContext } from "../types/befly";
6
+ import type { Plugin } from "../types/plugin";
7
+ import type { ScanFileResult } from "../utils/scanFiles";
8
+ export declare function loadPlugins(plugins: ScanFileResult[], context: BeflyContext): Promise<Plugin[]>;
@@ -2,19 +2,18 @@
2
2
  * 插件加载器
3
3
  * 负责扫描和初始化所有插件(核心、组件、项目)
4
4
  */
5
- import { Logger } from "../lib/logger.js";
6
- import { sortModules } from "../utils/sortModules.js";
7
- export async function loadPlugins(plugins, context, disablePlugins = []) {
5
+ import { Logger } from "../lib/logger";
6
+ import { sortModules } from "../utils/sortModules";
7
+ export async function loadPlugins(plugins, context) {
8
8
  const pluginsMap = [];
9
- if (disablePlugins.length > 0) {
10
- Logger.info({ plugins: disablePlugins }, "禁用插件");
11
- }
12
9
  const enabledPlugins = plugins.filter((item) => {
13
10
  const moduleName = item?.moduleName;
14
11
  if (typeof moduleName !== "string" || moduleName.trim() === "") {
15
12
  return false;
16
13
  }
17
- if (disablePlugins.includes(moduleName)) {
14
+ // enable=false 表示禁用(替代 disablePlugins 列表)。
15
+ // enable 仅允许 boolean;缺失 enable 的默认值应在 checkPlugin 阶段被补全为 true。
16
+ if (item?.enable === false) {
18
17
  return false;
19
18
  }
20
19
  return true;
@@ -31,6 +30,7 @@ export async function loadPlugins(plugins, context, disablePlugins = []) {
31
30
  context[pluginName] = pluginInstance;
32
31
  pluginsMap.push({
33
32
  name: pluginName,
33
+ enable: true,
34
34
  deps: plugin.deps,
35
35
  handler: plugin.handler
36
36
  });
@@ -2,12 +2,14 @@
2
2
  * 缓存插件 - TypeScript 版本
3
3
  * 负责在服务器启动时缓存接口、菜单和角色权限到 Redis
4
4
  */
5
- import type { BeflyContext } from "../types/befly.ts";
6
- import { CacheHelper } from "../lib/cacheHelper.ts";
5
+ import type { BeflyContext } from "../types/befly";
6
+ import { CacheHelper } from "../lib/cacheHelper";
7
7
  /**
8
8
  * 缓存插件
9
9
  */
10
10
  declare const _default: {
11
+ name: string;
12
+ enable: true;
11
13
  deps: string[];
12
14
  handler(befly: BeflyContext): Promise<CacheHelper>;
13
15
  };
@@ -2,11 +2,13 @@
2
2
  * 缓存插件 - TypeScript 版本
3
3
  * 负责在服务器启动时缓存接口、菜单和角色权限到 Redis
4
4
  */
5
- import { CacheHelper } from "../lib/cacheHelper.js";
5
+ import { CacheHelper } from "../lib/cacheHelper";
6
6
  /**
7
7
  * 缓存插件
8
8
  */
9
9
  export default {
10
+ name: "cache",
11
+ enable: true,
10
12
  deps: ["logger", "redis", "db"],
11
13
  async handler(befly) {
12
14
  if (!befly.db) {
@@ -2,8 +2,10 @@
2
2
  * Cipher 插件
3
3
  * 提供加密解密功能
4
4
  */
5
- import { Cipher } from "../lib/cipher.ts";
5
+ import { Cipher } from "../lib/cipher";
6
6
  declare const _default: {
7
+ name: string;
8
+ enable: true;
7
9
  deps: never[];
8
10
  handler: () => typeof Cipher;
9
11
  };
@@ -2,8 +2,10 @@
2
2
  * Cipher 插件
3
3
  * 提供加密解密功能
4
4
  */
5
- import { Cipher } from "../lib/cipher.js";
5
+ import { Cipher } from "../lib/cipher";
6
6
  export default {
7
+ name: "cipher",
8
+ enable: true,
7
9
  deps: [],
8
10
  handler: () => {
9
11
  return Cipher;
@@ -2,9 +2,11 @@
2
2
  * 配置插件
3
3
  * 提供访问项目配置的能力
4
4
  */
5
- import type { BeflyContext } from "../types/befly.ts";
5
+ import type { BeflyContext } from "../types/befly";
6
6
  declare const _default: {
7
+ name: string;
8
+ enable: true;
7
9
  deps: never[];
8
- handler: (context: BeflyContext) => import("../types/befly.ts").BeflyOptions;
10
+ handler: (context: BeflyContext) => import("../types/befly").BeflyOptions;
9
11
  };
10
12
  export default _default;
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ name: "config",
3
+ enable: true,
2
4
  deps: [],
3
5
  handler: (context) => {
4
6
  return context.config;
@@ -2,12 +2,14 @@
2
2
  * 数据库插件
3
3
  * 初始化数据库连接和 SQL 管理器
4
4
  */
5
- import type { BeflyContext } from "../types/befly.ts";
6
- import { DbHelper } from "../lib/dbHelper.ts";
5
+ import type { BeflyContext } from "../types/befly";
6
+ import { DbHelper } from "../lib/dbHelper";
7
7
  /**
8
8
  * 数据库插件
9
9
  */
10
10
  declare const _default: {
11
+ name: string;
12
+ enable: true;
11
13
  deps: string[];
12
14
  handler(befly: BeflyContext): Promise<DbHelper>;
13
15
  };
@@ -2,14 +2,16 @@
2
2
  * 数据库插件
3
3
  * 初始化数据库连接和 SQL 管理器
4
4
  */
5
- import { Connect } from "../lib/connect.js";
6
- import { getDialectByName } from "../lib/dbDialect.js";
7
- import { DbHelper } from "../lib/dbHelper.js";
8
- import { Logger } from "../lib/logger.js";
5
+ import { Connect } from "../lib/connect";
6
+ import { getDialectByName } from "../lib/dbDialect";
7
+ import { DbHelper } from "../lib/dbHelper";
8
+ import { Logger } from "../lib/logger";
9
9
  /**
10
10
  * 数据库插件
11
11
  */
12
12
  export default {
13
+ name: "db",
14
+ enable: true,
13
15
  deps: ["logger", "redis"],
14
16
  async handler(befly) {
15
17
  if (!befly.redis) {
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * JWT 插件
3
3
  */
4
- import type { BeflyContext } from "../types/befly.ts";
5
- import { Jwt } from "../lib/jwt.ts";
4
+ import type { BeflyContext } from "../types/befly";
5
+ import { Jwt } from "../lib/jwt";
6
6
  declare const _default: {
7
+ name: string;
8
+ enable: true;
7
9
  deps: never[];
8
10
  handler: (context: BeflyContext) => Jwt;
9
11
  };
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * JWT 插件
3
3
  */
4
- import { Jwt } from "../lib/jwt.js";
4
+ import { Jwt } from "../lib/jwt";
5
5
  export default {
6
+ name: "jwt",
7
+ enable: true,
6
8
  deps: [],
7
9
  handler: (context) => {
8
10
  return new Jwt(context.config ? context.config.auth : undefined);
@@ -2,11 +2,13 @@
2
2
  * 日志插件
3
3
  * 提供全局日志功能
4
4
  */
5
- import type { BeflyContext } from "../types/befly.ts";
5
+ import type { BeflyContext } from "../types/befly";
6
6
  /**
7
7
  * 日志插件
8
8
  */
9
9
  declare const _default: {
10
+ name: string;
11
+ enable: true;
10
12
  deps: never[];
11
13
  handler(context: BeflyContext): Promise<{
12
14
  info(...args: [] | [msg: string, ...args: unknown[]] | [msg: string, err: Error, ...args: unknown[]] | [err: Error, msg?: string | undefined, ...args: unknown[]] | [obj: {
@@ -21,8 +23,10 @@ declare const _default: {
21
23
  debug(...args: [] | [msg: string, ...args: unknown[]] | [msg: string, err: Error, ...args: unknown[]] | [err: Error, msg?: string | undefined, ...args: unknown[]] | [obj: {
22
24
  [x: string]: any;
23
25
  }, msg?: string | undefined, ...args: unknown[]]): any;
24
- configure: typeof import("../lib/logger.ts").configure;
25
- setMock: typeof import("../lib/logger.ts").setMockLogger;
26
+ flush(): Promise<void>;
27
+ configure: typeof import("../lib/logger").configure;
28
+ setMock: typeof import("../lib/logger").setMockLogger;
29
+ shutdown: typeof import("../lib/logger").shutdown;
26
30
  }>;
27
31
  };
28
32
  export default _default;
@@ -2,11 +2,13 @@
2
2
  * 日志插件
3
3
  * 提供全局日志功能
4
4
  */
5
- import { Logger } from "../lib/logger.js";
5
+ import { Logger } from "../lib/logger";
6
6
  /**
7
7
  * 日志插件
8
8
  */
9
9
  export default {
10
+ name: "logger",
11
+ enable: true,
10
12
  deps: [],
11
13
  async handler(context) {
12
14
  // 配置 Logger
@@ -2,12 +2,14 @@
2
2
  * Redis 插件
3
3
  * 初始化 Redis 连接和助手工具
4
4
  */
5
- import type { BeflyContext } from "../types/befly.ts";
6
- import { RedisHelper } from "../lib/redisHelper.ts";
5
+ import type { BeflyContext } from "../types/befly";
6
+ import { RedisHelper } from "../lib/redisHelper";
7
7
  /**
8
8
  * Redis 插件
9
9
  */
10
10
  declare const _default: {
11
+ name: string;
12
+ enable: true;
11
13
  deps: string[];
12
14
  handler(context: BeflyContext): Promise<Record<string, never> | RedisHelper>;
13
15
  };
@@ -2,13 +2,15 @@
2
2
  * Redis 插件
3
3
  * 初始化 Redis 连接和助手工具
4
4
  */
5
- import { Connect } from "../lib/connect.js";
6
- import { Logger } from "../lib/logger.js";
7
- import { RedisHelper } from "../lib/redisHelper.js";
5
+ import { Connect } from "../lib/connect";
6
+ import { Logger } from "../lib/logger";
7
+ import { RedisHelper } from "../lib/redisHelper";
8
8
  /**
9
9
  * Redis 插件
10
10
  */
11
11
  export default {
12
+ name: "redis",
13
+ enable: true,
12
14
  deps: ["logger"],
13
15
  async handler(context) {
14
16
  const redisConfig = context.config && context.config.redis ? context.config.redis : {};
@@ -2,7 +2,7 @@
2
2
  * 工具插件
3
3
  * 提供常用的工具函数
4
4
  */
5
- import type { RequestContext } from "../types/context.ts";
5
+ import type { RequestContext } from "../types/context";
6
6
  /**
7
7
  * 成功响应
8
8
  * @param msg - 消息
@@ -69,6 +69,8 @@ interface ResponseOptions {
69
69
  */
70
70
  export declare function Raw(ctx: RequestContext, data: Record<string, any> | string, options?: ResponseOptions): Response;
71
71
  declare const _default: {
72
+ name: string;
73
+ enable: true;
72
74
  deps: never[];
73
75
  handler: () => {
74
76
  Yes: typeof Yes;
@@ -91,6 +91,8 @@ export function Raw(ctx, data, options = {}) {
91
91
  });
92
92
  }
93
93
  export default {
94
+ name: "tool",
95
+ enable: true,
94
96
  deps: [],
95
97
  handler: () => {
96
98
  return {
@@ -2,9 +2,9 @@
2
2
  * API路由处理器
3
3
  * 处理 /api/* 路径的请求
4
4
  */
5
- import type { ApiRoute } from "../types/api.ts";
6
- import type { BeflyContext } from "../types/befly.ts";
7
- import type { Hook } from "../types/hook.ts";
5
+ import type { ApiRoute } from "../types/api";
6
+ import type { BeflyContext } from "../types/befly";
7
+ import type { Hook } from "../types/hook";
8
8
  /**
9
9
  * API处理器工厂函数
10
10
  * @param apis - API路由映射表
@@ -2,12 +2,12 @@
2
2
  * API路由处理器
3
3
  * 处理 /api/* 路径的请求
4
4
  */
5
- import { withCtx } from "../lib/asyncContext.js";
6
- import { Logger } from "../lib/logger.js";
5
+ import { withCtx } from "../lib/asyncContext";
6
+ import { Logger } from "../lib/logger";
7
7
  // 相对导入
8
- import { genShortId } from "../utils/genShortId.js";
9
- import { getClientIp } from "../utils/getClientIp.js";
10
- import { FinalResponse } from "../utils/response.js";
8
+ import { getClientIp } from "../utils/getClientIp";
9
+ import { FinalResponse } from "../utils/response";
10
+ import { genShortId } from "../utils/util";
11
11
  /**
12
12
  * API处理器工厂函数
13
13
  * @param apis - API路由映射表
@@ -2,7 +2,7 @@
2
2
  * 静态文件路由处理器
3
3
  * 处理 /* 路径的静态文件请求
4
4
  */
5
- import type { CorsConfig } from "../types/befly.ts";
5
+ import type { CorsConfig } from "../types/befly";
6
6
  /**
7
7
  * 静态文件处理器工厂
8
8
  */
@@ -4,10 +4,10 @@
4
4
  */
5
5
  // 外部依赖
6
6
  import { join } from "pathe";
7
- import { Logger } from "../lib/logger.js";
7
+ import { Logger } from "../lib/logger";
8
8
  // 相对导入
9
- import { appDir } from "../paths.js";
10
- import { setCorsOptions } from "../utils/cors.js";
9
+ import { appDir } from "../paths";
10
+ import { setCorsOptions } from "../utils/cors";
11
11
  /**
12
12
  * 静态文件处理器工厂
13
13
  */