src/components/server.js
/**
   * Start the server by receiving in args the init.
   *  server returned by [init method]{@link components/server#init}
   *  - Listen to the specified port.
   *  - Attach all necessary listeners.
   *
   * @param {any} app The Init server returned by
   *  [init method]{@link components/server#init}
   * @return {Promise}
   *  - a pending containing the server address.
   *  - otherwise, a rejected with a friendly error message.
   */
Start the server by receiving in args the init.
server returned by [init method] components/server#init
- Listen to the specified port.
- Attach all necessary listeners.

@param {any} app The Init server returned by
[init method] components/server#init
@return {Promise}
- a pending containing the server address.
- otherwise, a rejected with a friendly error message.
Start the server by receiving in args the init . server returned by [ init method ] components / server#init - Listen to the specified port . - Attach all necessary listeners . @param { any } app The Init server returned by [ init method ] components / server#init @return { Promise } - a pending containing the server address . - otherwise a rejected with a friendly error message .
start() {
    return new Promise((resolve, reject) => {
      const server = this.app_.listen(this.numPort_);
      server.on('listening', (err) => resolve(server.address()));
      server.on('close', () => Logger.warn('Missing fct to close the server'));
      server.on('error', (err) => {
        if (err.syscall !== 'listen') {
          throw err; 
        }
        let errMsg = undefined;
        switch (err.code) {
          case 'EACCES':
            errMsg = 'Port :' + this.numPort_ + ' need to be admin';
            break;
          case 'EADDRINUSE':
            errMsg = 'Port :' + this.numPort_ + ' is already in use.\n';
            break;
          default:
            errMsg = err.message;
        }
        reject(new Error(errMsg, err));
      });
    });
  }
start ( ) { return new Promise ( ( resolve , reject ) => { const server = this . app_ . listen ( this . numPort_ ) ; server . on ( 'listening' , ( err ) => resolve ( server . address ( ) ) ) ; server . on ( 'close' , ( ) => Logger . warn ( 'Missing fct to close the server' ) ) ; server . on ( 'error' , ( err ) => { if ( err . syscall !== 'listen' ) { throw err ; } let errMsg = undefined ; switch ( err . code ) { case 'EACCES' : errMsg = 'Port :' + this . numPort_ + ' need to be admin' ; break ; case 'EADDRINUSE' : errMsg = 'Port :' + this . numPort_ + ' is already in use.\n' ; break ; default : errMsg = err . message ; } reject ( new Error ( errMsg , err ) ) ; } ) ; } ) ; }
Start the server by receiving in args the init.
Start the server by receiving in args the init .
// Wasn't listen yet ! // handle specific listen errors with friendly messages