File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ import policies from "./routes/policies.js";
1717import roleAssignments from "./routes/role-assignments.js" ;
1818import roles from "./routes/roles.js" ;
1919import type { AuthStorage } from "./storage/index.js" ;
20- import { createSqliteStorage } from "./storage/sqlite.js" ;
2120
2221const 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
You can’t perform that action at this time.
0 commit comments