Skip to content

Commit

Permalink
Merge pull request #34 from kuzivany/jsdoc
Browse files Browse the repository at this point in the history
Add Intellisense
  • Loading branch information
thgh committed Jan 27, 2019
2 parents 1ea9096 + b139780 commit 0154280
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/index.js
Expand Up @@ -8,7 +8,11 @@ import opener from 'opener'

let server

export default function serve (options = { contentBase: '' }) {
/**
* Serve your rolled up bundle like webpack-dev-server
* @param {ServeOptions|string|string[]} options
*/
function serve (options = { contentBase: '' }) {
if (Array.isArray(options) || typeof options === 'string') {
options = { contentBase: options }
}
Expand Down Expand Up @@ -136,3 +140,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<string|Buffer>} cert
* @property {string|Buffer|Array<string|Buffer>} ca
* @see https.ServerOptions
*/

0 comments on commit 0154280

Please sign in to comment.