diff --git a/src/index.ts b/src/index.ts index 648f58c..b0c7f0d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,9 +38,9 @@ export interface ListenOptions { export interface Listener { url: string, - getURL: (url: string) => string, server: http.Server | https.Server, - close: () => Promise + close: () => Promise, + open: () => Promise } export async function listen (handle: http.RequestListener, opts: Partial = {}): Promise { @@ -115,9 +115,12 @@ export async function listen (handle: http.RequestListener, opts: Partial { const { default: open } = await import('open') - await open(url).catch(() => {}) + await open(url).catch(() => { }) + } + if (opts.open) { + await _open() } if (opts.autoClose) { @@ -127,6 +130,7 @@ export async function listen (handle: http.RequestListener, opts: Partial{ url, server, + open: _open, close } }