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
-**port**: server port. Default: `0` (i.e., randomly assigned).
55
60
-**maxport**: max server port when port hunting. Default: `maxport=port`.
56
61
-**hostname**: server hostname.
57
62
-**address**: server address. Default: `127.0.0.1`.
58
63
59
-
To specify server options, provide an `options` object.
64
+
To specify server options, provide an options object.
60
65
61
66
```javascript
62
67
var opts = {
63
68
'port':7331,
64
69
'address':'0.0.0.0'
65
70
};
66
71
67
-
varcreateServer=httpServer( opts );
72
+
varhttpServer=httpServerFactory( opts );
68
73
```
69
74
70
75
To specify a range of permissible ports, set the `maxport` option.
@@ -74,14 +79,14 @@ var opts = {
74
79
'maxport':9999
75
80
};
76
81
77
-
varcreateServer=httpServer( opts );
82
+
varhttpServer=httpServerFactory( opts );
78
83
```
79
84
80
85
When provided a `maxport` option, a created server will search for the first available `port` on which to listen, starting from `port`.
81
86
82
-
#### createServer( done )
87
+
#### httpServer( \[options,] done )
83
88
84
-
Creates an [HTTP][http] server.
89
+
Creates an [HTTP][nodejs-http] server.
85
90
86
91
```javascript
87
92
functiondone( error, server ) {
@@ -92,11 +97,16 @@ function done( error, server ) {
92
97
server.close();
93
98
}
94
99
95
-
varcreateServer=httpServer();
100
+
varhttpServer=httpServerFactory();
96
101
97
-
createServer( done );
102
+
httpServer( done );
98
103
```
99
104
105
+
The function supports the following parameters:
106
+
107
+
-**options**: server options which are passed directly to [`http.createServer`][nodejs-http-create-server]. Which options are supported depends on the Node.js version. Older Node.js versions (e.g., <= v8.12.0) do not support an options object, and, for those versions, a provided options object is ignored.
108
+
-**done**: callback to invoke once a server is listening and ready to handle requests.
0 commit comments