You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+21-5Lines changed: 21 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,8 @@ polka()
59
59
console.log(`~> Hello, ${req.hello}`);
60
60
res.end(`User: ${req.params.id}`);
61
61
})
62
-
.listen(3000).then(_=> {
62
+
.listen(3000, err=> {
63
+
if (err) throw err;
63
64
console.log(`> Running on localhost:3000`);
64
65
});
65
66
```
@@ -77,7 +78,7 @@ Type: `Server`<br>
77
78
78
79
A custom, instantiated server that the Polka instance should attach its [`handler`](#handlerreq-res-parsed) to. This is useful if you have initialized a server elsewhere in your application and want Polka to use _it_ instead of creating a new `http.Server`.
79
80
80
-
Polka _only_ updates the server when [`polka.listen`](#listenport-hostname) is called. At this time, Polka will create a [`http.Server`](https://nodejs.org/api/http.html#http_class_http_server) if a server was not provided via `options.server`.
81
+
Polka _only_ updates the server when [`polka.listen`](#listen) is called. At this time, Polka will create a [`http.Server`](https://nodejs.org/api/http.html#http_class_http_server) if a server was not already provided via `options.server`.
81
82
82
83
> **Important:** The `server` key will be `undefined` until `polka.listen` is invoked, unless a server was provided.
Wraps the native [`server.listen`](https://nodejs.org/dist/latest-v9.x/docs/api/http.html#http_server_listen) with a Promise, rejecting on any error.
142
+
Boots (or creates) the underlying [`http.Server`](https://nodejs.org/dist/latest-v9.x/docs/api/http.html#http_class_http_server) for the first time. All arguments are passed to [`server.listen`](https://nodejs.org/dist/latest-v9.x/docs/api/net.html#net_server_listen) directly with no changes.
143
+
144
+
As of `v0.5.0`, this method no longer returns a Promise. Instead, the current Polka instance is returned directly, allowing for chained operations.
0 commit comments