text: 'use strict';
  
  // Settings
  const defaults = require('../settings/default');
  
  // Dependencies
  const Node = require('@fabric/core/types/node');
  
  // Services
  const HubService = require('../services/hub');
  
  // Configuration
  const settings = {
    listen: true,
    port: process.env.FABRIC_PORT || defaults.port,
    seed: process.env.FABRIC_SEED || defaults.seed
  };
  
  // Main process
  async function main (input = {}) {
    const hub = new Node({
      service: HubService,
      settings: input
    });
  
    hub.on('ready', function (node) {
      console.log('[FABRIC:HUB]', `Hub is now started, pubkey ${hub.key.pubkey} listening on:`, node.address);
    });
  
    hub.on('peer', function (peer) {
      console.log('[FABRIC:HUB]', `New peer connected: ${JSON.stringify(peer)}`);
    });
  
    hub.on('connections:close', function (peer) {
      console.log('[FABRIC:HUB]', `Peer closed connection: ${JSON.stringify(peer)}`);
    });
  
    await hub.start();
  
    return {
      id: hub.id
    };
  }
  
  // Start & handle errors
  main(settings).catch((exception) => {
    console.error('[FABRIC:HUB]', 'Main process threw Exception:', exception);
  });
  