Skip to content

Commit 5b4748c

Browse files
Add programmatic start() API alongside CLI (#56) (#57)
Split jspod into: - lib/start.js — exports start(options) returning a handle { url, port, host, root, ready, exit, stop }. Pod-startup logic, no process.exit, no banner, no signal handlers. - lib/index.js — barrel export ({ start, formatUrl }). - index.js — thin CLI shell. argv parsing, banner, install subcommand, SIGINT/SIGTERM handlers that call handle.stop() then process.exit. Behaviour identical to pre-refactor CLI. package.json gets main + exports map pointing at lib/index.js, so `import { start } from 'jspod'` works for host programs (e.g. solid-desktop) that want to embed jspod in-process instead of spawning the CLI as a child. Smoke-tested both surfaces: - CLI: node index.js --port 5455 --no-bootstrap → ready, served GET /, SIGINT → clean SIGTERM to JSS → exit 0. - API: start({ port, root, open:false, bootstrap:false }) → ready resolves true, fetch returns 200, stop() returns {code:0,signal:null} and is idempotent. - Bare-specifier import via `file:` install → imports 'jspod' and gets { start, formatUrl } as expected.
1 parent b1a2860 commit 5b4748c

4 files changed

Lines changed: 390 additions & 439 deletions

File tree

0 commit comments

Comments
 (0)