{"size": 820, "ext": "js", "max_stars_repo_path": "node_modules/cooking/util/load-server.js", "max_stars_repo_name": "testted123456/vue-element", "max_stars_repo_stars_event_min_datetime": "2016-03-11T11:30:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T17:57:35.000Z", "max_issues_repo_path": "packages/cooking/util/load-server.js", "max_issues_repo_name": "sunxia628/cooking", "max_issues_repo_issues_event_min_datetime": "2016-03-28T10:58:10.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-07T03:00:21.000Z", "max_forks_repo_path": "packages/cooking/util/load-server.js", "max_forks_repo_name": "sunxia628/cooking", "max_forks_repo_forks_event_min_datetime": "2016-04-25T09:47:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-04T13:10:44.000Z"}
{"max_stars_count": 2317, "max_issues_count": 152, "max_forks_count": 397, "avg_line_length": 20.5, "max_line_length": 90, "alphanum_fraction": 0.6256097561}
'use strict'

const isObject = require('./is').Object
const defaultServer = {
  port: 8080,
  hot: true,
  log: true,
  enable: true,
  historyApiFallback: true,
  lazy: false,
  stats: 'errors-only',
  host: '0.0.0.0',
  disableHostCheck: true,
  __host__: 'http://0.0.0.0:8080'
}

module.exports = server => {
  // null, undefined, false
  if (!server || server === false) {
    return {
      enable: false,
      stats: 'errors-only'
    }
  }

  // object
  if (isObject(server)) {
    const config = Object.assign(defaultServer, server)

    config.host = config.hostname || config.host || defaultServer.host
    config.__host__ = `${config.https ? 'https' : 'http'}://${config.host}:${config.port}`
    delete config.hostname

    return config
  }

  // array, string, true, number .etc
  return defaultServer
}
