Skip to content

Commit 5a5549a

Browse files
authored
Merge pull request #14 from AgentWorkforce/fix-export-for-cloud
dynamic import to not conflict
2 parents 94dff99 + 670c83e commit 5a5549a

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packages/server/src/server.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import policies from "./routes/policies.js";
1717
import roleAssignments from "./routes/role-assignments.js";
1818
import roles from "./routes/roles.js";
1919
import type { AuthStorage } from "./storage/index.js";
20-
import { createSqliteStorage } from "./storage/sqlite.js";
2120

2221
const PUBLIC_PATHS = new Set([
2322
"/health",
@@ -159,9 +158,16 @@ export function createApp(options: CreateAppOptions = {}): Hono<AppEnv> {
159158
return app;
160159
}
161160

162-
export function startServer(options: StartServerOptions = {}) {
161+
export async function startServer(options: StartServerOptions = {}) {
163162
const port = Number.isFinite(options.port) ? (options.port as number) : 8787;
164-
const storage = options.storage ?? createSqliteStorage(options.dbPath);
163+
let storage: AuthStorage;
164+
if (options.storage) {
165+
storage = options.storage;
166+
} else {
167+
// Dynamic import to avoid bundling sqlite (uses Function()) in Workers
168+
const { createSqliteStorage } = await import("./storage/sqlite.js");
169+
storage = createSqliteStorage(options.dbPath);
170+
}
165171
const internalSecret =
166172
options.config?.INTERNAL_SECRET
167173
?? process.env.INTERNAL_SECRET

0 commit comments

Comments
 (0)