befly 3.17.2 → 3.17.3
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/index.js +27 -19
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -166,20 +166,38 @@ export class Befly {
|
|
|
166
166
|
return instance;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
ensureCreatedByFactory(methodName) {
|
|
170
|
+
if (this.createdByFactory) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
throw new Error(`请使用 Befly.create(...) 创建实例后再调用 ${methodName}`, {
|
|
175
|
+
cause: null,
|
|
176
|
+
code: "policy",
|
|
177
|
+
subsystem: methodName === "start" ? "start" : "syncDb",
|
|
178
|
+
operation: "factoryGuard"
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async dbCheck() {
|
|
183
|
+
this.ensureCreatedByFactory("dbCheck");
|
|
184
|
+
|
|
185
|
+
return syncDbCheck(this.context.config.mysql);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async dbApply() {
|
|
189
|
+
this.ensureCreatedByFactory("dbApply");
|
|
190
|
+
|
|
191
|
+
return syncDbApply(this.context.config.mysql);
|
|
192
|
+
}
|
|
193
|
+
|
|
169
194
|
/**
|
|
170
195
|
* 启动完整的生命周期流程
|
|
171
196
|
* @returns HTTP 服务器实例
|
|
172
197
|
*/
|
|
173
198
|
async start() {
|
|
174
199
|
try {
|
|
175
|
-
|
|
176
|
-
throw new Error("请使用 Befly.create(...) 创建实例后再调用 start", {
|
|
177
|
-
cause: null,
|
|
178
|
-
code: "policy",
|
|
179
|
-
subsystem: "start",
|
|
180
|
-
operation: "factoryGuard"
|
|
181
|
-
});
|
|
182
|
-
}
|
|
200
|
+
this.ensureCreatedByFactory("start");
|
|
183
201
|
|
|
184
202
|
const serverStartTime = Bun.nanoseconds();
|
|
185
203
|
if (!Array.isArray(this.scanApis) || !Array.isArray(this.scanPlugins) || !Array.isArray(this.scanHooks)) {
|
|
@@ -313,14 +331,4 @@ export class Befly {
|
|
|
313
331
|
}
|
|
314
332
|
}
|
|
315
333
|
|
|
316
|
-
|
|
317
|
-
const mergedConfig = deepMerge(beflyConfig, config);
|
|
318
|
-
return syncDbCheck(mergedConfig.mysql);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
async function dbApply(config = {}) {
|
|
322
|
-
const mergedConfig = deepMerge(beflyConfig, config);
|
|
323
|
-
return syncDbApply(mergedConfig.mysql);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
export { dbApply, dbCheck, Logger };
|
|
334
|
+
export { Logger };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly",
|
|
3
|
-
"version": "3.17.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "3.17.3",
|
|
4
|
+
"gitHead": "91bea63e1267eeaa8d0fd152686eb122ce30a4b1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Befly - 为 Bun 专属打造的 JavaScript API 接口框架核心引擎",
|
|
7
7
|
"keywords": [
|