src/components/boot.js
/**
   * Init the boot action.
   *
   * @return {Promise} a pending Promise
   *  with nothing or reject with the error.
   */
Init the boot action.
@return {Promise} a pending Promise
with nothing or reject with the error.
Init the boot action . @return { Promise } a pending Promise with nothing or reject with the error .
static async start() {
    const server = new Server(process.env.PORT || Config.api.port);
    let stats;
    try {
      Logger.info('[BOOT]\t App is running');
      try {
        stats = await Promise.promisify(fs.stat)(Config.api.dirLogs);
        checkIfSetup(null, stats.isDirectory()); 
      } catch (err) {
        checkIfSetup(err); 
      }
      Logger.info('[BOOT]\t Check logs folder: OK');
      const app = await server.init(routes_.map((rt) => rt.init()));
      Logger.info('[BOOT]\t Init Routes for server : OK');
      Logger.info('[BOOT]\t Starting server .... ');
      const {
        address = 'localhost',
        port,
      } = await server.start();
      Logger.info('[BOOT]\t Server Ready');
      Logger.info(`[BOOT]\t Server Listening on http://${address}:${port}`);
      Logger.info('[BOOT]\t App ready');
      return app;
    } catch (err) {
      if (err.code === 'EADDRINUSE') {
        Logger.error('[BOOT]\t Address already in use');
      }
      Logger.error(err);
      process.abort();
    }
  }
static async start ( ) { const server = new Server ( process . env . PORT || Config . api . port ) ; let stats ; try { Logger . info ( '[BOOT]\t App is running' ) ; try { stats = await Promise . promisify ( fs . stat ) ( Config . api . dirLogs ) ; checkIfSetup ( null , stats . isDirectory ( ) ) ; } catch ( err ) { checkIfSetup ( err ) ; } Logger . info ( '[BOOT]\t Check logs folder: OK' ) ; const app = await server . init ( routes_ . map ( ( rt ) => rt . init ( ) ) ) ; Logger . info ( '[BOOT]\t Init Routes for server : OK' ) ; Logger . info ( '[BOOT]\t Starting server .... ' ) ; const { address = 'localhost' , port , } = await server . start ( ) ; Logger . info ( '[BOOT]\t Server Ready' ) ; Logger . info ( ` \t ${ address } ${ port } ` ) ; Logger . info ( '[BOOT]\t App ready' ) ; return app ; } catch ( err ) { if ( err . code === 'EADDRINUSE' ) { Logger . error ( '[BOOT]\t Address already in use' ) ; } Logger . error ( err ) ; process . abort ( ) ; } }
Init the boot action.
Init the boot action .
// Log an error msg if not. // Must produce the same error msg for an error