slower 1.1.8 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/router.js CHANGED
@@ -270,7 +270,17 @@ class SlowerRouter {
270
270
  return this.allowedMethods;
271
271
  }
272
272
 
273
- start = function (port = 8080, callback) {
273
+ // Starts the server - listening at <host>:<port>
274
+ /**
275
+ * @category Router
276
+ * @param {Number} port The port number the server will listen to.
277
+ * @param {String} host The host's network interface address the server will listen into (use a falsy value or '0.0.0.0' for listening on all).
278
+ * @param {Function} methods The methods that are allowed by the application. Methods that do not conform with standards are ignored.
279
+ * @returns {Object} The AllowedMethods Array object.
280
+ * @example <caption> Allowing only GET and POST:</caption>
281
+ * app.setAllowedMethods(['GET', 'POST']);
282
+ */
283
+ start = function (port = 8080, host = undefined, callback = () => {}) {
274
284
  let routes = this.routes;
275
285
  let middle = this.middleware;
276
286
  let fallback = this.fallback;
@@ -307,7 +317,8 @@ class SlowerRouter {
307
317
  }
308
318
  });
309
319
  callback(server);
310
- return server.listen(port);
320
+ if (!host) host = undefined; // Turn falsy values into undefined, for default behaviour
321
+ return server.listen(port, host);
311
322
  }
312
323
  }
313
324
 
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "slower",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "directories": {
7
- "doc": "doc",
8
7
  "lib": "lib"
9
8
  },
10
9
  "scripts": {
package/readme.md CHANGED
@@ -41,7 +41,8 @@ app.setFallback((req, res) => {
41
41
  res.end();
42
42
  });
43
43
 
44
- app.start(port, () => {
44
+ // Start app listening on all interfaces (0.0.0.0)
45
+ app.start(port, null, () => {
45
46
  console.log(`Running on localhost:${port}`);
46
47
  console.log(app);
47
48
  });