Skip to content

Commit

Permalink
feat(wobe): add hostname on node and bun (#38)
Browse files Browse the repository at this point in the history
* feat(wobe): add hostname on node and bun

* fix: tests
  • Loading branch information
coratgerl authored Nov 21, 2024
1 parent 3f1ea9b commit 3a90c19
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/wobe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wobe",
"version": "1.1.8",
"version": "1.1.9",
"description": "A fast, lightweight and simple web framework",
"homepage": "https://wobe.dev",
"author": {
Expand Down
14 changes: 14 additions & 0 deletions packages/wobe/src/Wobe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@ describe('Wobe', () => {
},
)

it('should listen on different hostname', async () => {
const wobeTest = new Wobe({ hostname: '0.0.0.0' }).get(
'/health',
(ctx) => ctx.res.send('ok'),
)

wobeTest.listen(5555)

const res = await fetch('http://0.0.0.0:5555/health')
expect(await res.text()).toBe('ok')

wobeTest.stop()
})

it('should run options route', async () => {
await fetch(`http://127.0.0.1:${port}/options`, {
method: 'OPTIONS',
Expand Down
2 changes: 1 addition & 1 deletion packages/wobe/src/adapters/node/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const NodeAdapter = (): RuntimeAdapter => ({

res.end()
})
}).listen(port)
}).listen(port, options?.hostname)
},
stopServer: (server: any) => server.close(),
})

0 comments on commit 3a90c19

Please sign in to comment.