From caf8a50e53d6c28e3c4ead84787d3aa6301cc3a2 Mon Sep 17 00:00:00 2001 From: Kuzivakwashe Date: Wed, 23 Jan 2019 00:39:32 +0200 Subject: [PATCH 1/2] Add JSDoc --- src/index.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7e0ec03..941e137 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,10 @@ import opener from 'opener' let server -export default function serve (options = { contentBase: '' }) { +/** + * @param {ServeOptions|string|string[]} options + */ +function serve (options = { contentBase: '' }) { if (Array.isArray(options) || typeof options === 'string') { options = { contentBase: options } } @@ -136,3 +139,26 @@ function closeServerOnTermination (server) { }) }) } + +export default serve + +/** + * @typedef {Object} ServeOptions + * @property {boolean} [open=false] Launch in browser (default: `false`) + * @property {string} [openPage=''] Page to navigate to when opening the browser. Will not do anything if `open` is `false`. Remember to start with a slash e.g. `'/different/page'` + * @property {boolean} [verbose=true] Show server address in console (default: `true`) + * @property {string|string[]} [contentBase=''] Folder(s) to serve files from + * @property {string|boolean} [historyApiFallback] Path to fallback page. Set to `true` to return index.html (200) instead of error page (404) + * @property {string} [host='localhost'] Server host (default: `'localhost'`) + * @property {number} [port=10001] Server port (default: `10001`) + * @property {ServeOptionsHttps} [https=false] By default server will be served over HTTP (https: `false`). It can optionally be served over HTTPS + * @property {{[header:string]: string}} [headers] Set headers + */ + +/** + * @typedef {Object} ServeOptionsHttps + * @property {string|Buffer|Buffer[]|Object[]} key + * @property {string|Buffer|Array} cert + * @property {string|Buffer|Array} ca + * @see https.ServerOptions + */ From b1397803d9fd3eb01791605a1cdda8acaee4a7a6 Mon Sep 17 00:00:00 2001 From: Kuzivakwashe Date: Wed, 23 Jan 2019 00:52:58 +0200 Subject: [PATCH 2/2] Add JSDoc description --- src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.js b/src/index.js index 941e137..ec9ee3c 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,7 @@ import opener from 'opener' let server /** + * Serve your rolled up bundle like webpack-dev-server * @param {ServeOptions|string|string[]} options */ function serve (options = { contentBase: '' }) {