code: function _addPlugin(app, item) {
    if (!item.name || item.name === '') {
      try {
        if (typeof item.fn.publicName === 'string') item.name = item.fn.publicName;
      } catch (e) {
      }
    }
    item.name = item.name.trim();
    if (item.name.indexOf('thorin-plugin-') === 0) {  // thorin plugins have their name trimmed.
      item.name = item.name.substr(14);
    }
    let pluginConfig = app.config('plugin.' + item.name);
    if (pluginConfig) {
      item.opt = app.util.extend(pluginConfig, item.opt);
    }
    if (typeof item.fn === 'string') {
      item.fn = _requireModule(app.root, item.fn, item.opt);
    }
    if (typeof app[plugins][item.name] !== 'undefined') {
      throw new Error('Thorin.addPlugin: plugin ' + item.name + " is already registered. Please use a different name.");
    }
    /* Check if we have a constructor or an already created obj. */
    let pluginType = Object.prototype.toString.call(item.fn),
      pluginObj;
    if (pluginType === '[object Undefined]') {
      return; // we do not add it.
    }
    if (pluginType === '[object Object]') {
      pluginObj = item.fn;
      item.name = item.fn.name;
    } else if (typeof item.fn === 'function') {
      try {
        pluginObj = new item.fn(app, item.opt, item.name);
      } catch (e) {
        if (e.message.indexOf('item.fn is not a constructor') === 0) {
          pluginObj = item.fn(app, item.opt, item.name);
          if (typeof pluginObj !== 'object' || !pluginObj) return;
        } else {
          throw e;
        }
      }
    }
    app[plugins][item.name] = pluginObj;
  }
docs: /*
  Registers a new plugin.
  // TODO: handle init() and run() if the app is already