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 +13 -2
- package/package.json +1 -2
- package/readme.md +2 -1
package/lib/router.js
CHANGED
|
@@ -270,7 +270,17 @@ class SlowerRouter {
|
|
|
270
270
|
return this.allowedMethods;
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
|
|
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
|
-
|
|
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
package/readme.md
CHANGED