fix: replace Bun.serve with Node.js http module in auth-server

Summary

  • Fixed postgresai auth command failing with "Bun is not defined" error after the Node.js to Bun migration
  • Replaced Bun-specific Bun.serve() API with Node.js native http.createServer() in cli/lib/auth-server.ts

Problem

After the CLI migration to Bun (commit 1b1425a2), the auth command broke completely:

❯ postgresai auth
Starting authentication flow...
Starting local callback server...
Authentication error: Bun is not defined

Root cause: The auth-server.ts file used Bun.serve() which is a Bun-specific API. Since the CLI is compiled with bun build --target node, the Bun global doesn't exist at runtime.

Solution

Replaced the Bun.serve() implementation with Node.js native http.createServer():

  • Updated server creation to use http.createServer() callback pattern
  • Changed serverInstance.stop() to serverInstance.close()
  • Updated type annotations from ReturnType<typeof Bun.serve> to http.Server
  • Removed unused getServerPort() helper function

Testing

All CLI command groups verified working:

Command Group Status
Main (--version, help, prepare-db)
mon (17 subcommands)
auth (login, show-key, remove-key)
issues (list, view, post_comment)
mcp (start, install)

OAuth flow now works correctly:

Starting authentication flow...
Starting local callback server...
Callback server listening on port 36679 ✅
Initializing authentication session...

#69 (closed)

Merge request reports

Loading