Skip to content

Commit 3a4b8e2

Browse files
committed
fix: add host to listen method
1 parent faaa3e1 commit 3a4b8e2

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ server.get('/', ({ response }) => {
5858
.send({ hello: 'world!', param: ctx.data.param })
5959
})
6060

61-
server.listen(1335, () => console.log('Server running!'))
61+
server.listen().then(address => `Server running on address ${address}`)
6262
```
6363

6464
---

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/http",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "",
55
"license": "MIT",
66
"author": "João Lenon",

src/Http.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,8 @@ export class Http {
6565
this.server.addHook(hookName, FastifyHandler[handlerType](handler))
6666
}
6767

68-
listen(
69-
port?: number,
70-
cb?: (err: Error | null, address: string) => void,
71-
): void | string {
72-
return this.server.listen(port || 1335, cb)
68+
async listen(port?: string | number, host?: string): Promise<string> {
69+
return this.server.listen(port || 1335, host || '127.0.0.1')
7370
}
7471

7572
close(cb?: () => void): void {

0 commit comments

Comments
 (0)