cli/utils/server.js
function start(root, distPath) {
  return new Promise((resolve, reject) => {

    const dist = path.resolve(process.cwd(), distPath || 'dist');

    logger.info('Creating web server');
    app.use(cors());

    logger.info(`Exposing static directory: ${dist}`);
    app.use(express.static(dist));
    if (root) {
      logger.info(`Mapping server requests from ${root} to ${dist}`);
      app.use(root, express.static(dist));
    }

    const options = {
      cert: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.crt')),
      key: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.key'))
    };

    server = https.createServer(options, app);
    server.on('error', reject);

    logger.info('Requesting open port...');
    portfinder
      .getPortPromise()
      .then(port => {
        logger.info(`Open port found: ${port}`);
        logger.info('Starting web server...');
        server.listen(port, 'localhost', () => {
          logger.info('Web server running.');
          resolve(port);
        });
      })
      .catch(reject);
  });
}
function start(root, distPath) {
  return new Promise((resolve, reject) => {

    const dist = path.resolve(process.cwd(), distPath || 'dist');

    logger.info('Creating web server');
    app.use(cors());

    logger.info(`Exposing static directory: ${dist}`);
    app.use(express.static(dist));
    if (root) {
      logger.info(`Mapping server requests from ${root} to ${dist}`);
      app.use(root, express.static(dist));
    }

    const options = {
      cert: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.crt')),
      key: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.key'))
    };

    server = https.createServer(options, app);
    server.on('error', reject);

    logger.info('Requesting open port...');
    portfinder
      .getPortPromise()
      .then(port => {
        logger.info(`Open port found: ${port}`);
        logger.info('Starting web server...');
        server.listen(port, 'localhost', () => {
          logger.info('Web server running.');
          resolve(port);
        });
      })
      .catch(reject);
  });
}
function start ( root , distPath ) { return new Promise ( ( resolve , reject ) => { const dist = path . resolve ( process . cwd ( ) , distPath || 'dist' ) ; logger . info ( 'Creating web server' ) ; app . use ( cors ( ) ) ; logger . info ( ` ${ dist } ` ) ; app . use ( express . static ( dist ) ) ; if ( root ) { logger . info ( ` ${ root } ${ dist } ` ) ; app . use ( root , express . static ( dist ) ) ; } const options = { cert : fs . readFileSync ( path . resolve ( __dirname , '../../ssl/server.crt' ) ) , key : fs . readFileSync ( path . resolve ( __dirname , '../../ssl/server.key' ) ) } ; server = https . createServer ( options , app ) ; server . on ( 'error' , reject ) ; logger . info ( 'Requesting open port...' ) ; portfinder . getPortPromise ( ) . then ( port => { logger . info ( ` ${ port } ` ) ; logger . info ( 'Starting web server...' ) ; server . listen ( port , 'localhost' , ( ) => { logger . info ( 'Web server running.' ) ; resolve ( port ) ; } ) ; } ) . catch ( reject ) ; } ) ; }
Starts the httpServer
@name start
Starts the httpServer