Skip to content

Commit

Permalink
Return server URL from server manager
Browse files Browse the repository at this point in the history
  • Loading branch information
deptyped committed Jul 22, 2024
1 parent aa7b988 commit 7fde8ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ async function startWebhook(config: WebhookConfig) {
)
logger.info({
msg: 'Server started',
url:
info.family === 'IPv6'
? `http://[${info.address}]:${info.port}`
: `http://${info.address}:${info.port}`,
url: info.url,
})

// set webhook
Expand Down
9 changes: 6 additions & 3 deletions src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { AddressInfo } from 'node:net'
import { Hono } from 'hono'
import { HTTPException } from 'hono/http-exception'
import { serve } from '@hono/node-server'
Expand Down Expand Up @@ -77,14 +76,18 @@ export function createServerManager(server: Server) {
let handle: undefined | ReturnType<typeof serve>
return {
start: (host: string, port: number) =>
new Promise<AddressInfo>((resolve) => {
new Promise<{ url: string }>((resolve) => {
handle = serve(
{
fetch: server.fetch,
hostname: host,
port,
},
info => resolve(info),
info => resolve({
url: info.family === 'IPv6'
? `http://[${info.address}]:${info.port}`
: `http://${info.address}:${info.port}`,
}),
)
}),
stop: () =>
Expand Down

0 comments on commit 7fde8ae

Please sign in to comment.