Skip to content

Commit a8edd57

Browse files
committed
重构服务器启动逻辑,将插件加载移至异步启动,更新 pnpm-lock.yaml 以包含 BI 插件依赖
1 parent b84742b commit a8edd57

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

examples/server/src/index.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ app.use('*', logger());
1414
app.use('*', cors());
1515

1616
// 2. Load Plugins (CRM, Todo)
17-
console.log('--- Starting ObjectStack Server ---');
18-
await loadPlugins();
19-
console.log('--- Plugins Loaded ---');
17+
// Initialization moved to async startup below
2018

2119
// 3. Define Unified Routes
2220

@@ -188,9 +186,20 @@ app.delete('/api/v1/data/:object/:id', async (c) => {
188186

189187
// 4. Start Server
190188
const port = 3004;
191-
console.log(`Server is running on http://localhost:${port}`);
192189

193-
serve({
194-
fetch: app.fetch,
195-
port
196-
});
190+
(async () => {
191+
console.log('--- Starting ObjectStack Server ---');
192+
try {
193+
await loadPlugins();
194+
console.log('--- Plugins Loaded ---');
195+
} catch (err) {
196+
console.error('Failed to load plugins:', err);
197+
}
198+
199+
console.log(`Server is running on http://localhost:${port}`);
200+
201+
serve({
202+
fetch: app.fetch,
203+
port
204+
});
205+
})();

examples/server/src/loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function loadPlugins() {
3535
// 2. Load Runtime (Dynamic Simulation)
3636
// In a real engine, this would use `import(manifest.extensions.runtime.entry)`
3737
if (manifest.id === 'com.objectstack.bi' && BiPluginRuntime) {
38-
const pluginDef = BiPluginRuntime.default || BiPluginRuntime;
38+
const pluginDef = (BiPluginRuntime as any).default || BiPluginRuntime;
3939

4040
if (pluginDef.onEnable) {
4141
console.log(`[Loader] Executing Plugin Runtime: ${manifest.id}`);

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)