# All files / lib/server index.js

100% Statements 36/36
80% Branches 8/10
100% Functions 7/7
100% Lines 36/36

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    10x

    1x
    19x
    19x

    19x

    15x

    2x

    2x

    228x
    1216x
    1007x

    209x

     'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.closeProxyServer = closeProxyServer;

    var _postmsgRpc = require('postmsg-rpc');

    var _prepost = require('prepost');

    var _block = require('./block');

    var _block2 = _interopRequireDefault(_block);

    var _config = require('./config');

    var _config2 = _interopRequireDefault(_config);

    var _dag = require('./dag');

    var _dag2 = _interopRequireDefault(_dag);

    var _dht = require('./dht');

    var _dht2 = _interopRequireDefault(_dht);

    var _files = require('./files');

    var _files2 = _interopRequireDefault(_files);

    var _key = require('./key');

    var _key2 = _interopRequireDefault(_key);

    var _object = require('./object');

    var _object2 = _interopRequireDefault(_object);

    var _pin = require('./pin');

    var _pin2 = _interopRequireDefault(_pin);

    var _pubsub = require('./pubsub');

    var _pubsub2 = _interopRequireDefault(_pubsub);

    var _swarm = require('./swarm');

    var _swarm2 = _interopRequireDefault(_swarm);

    function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

    exports.default = function (getIpfs, opts) {
      opts = opts || {};
      opts.pre = opts.pre || {};

      return {
        id: (0, _postmsgRpc.expose)('ipfs.id', (0, _prepost.pre)(opts.pre.id, function () {
          return getIpfs().id();
        }), opts),
        version: (0, _postmsgRpc.expose)('ipfs.version', (0, _prepost.pre)(opts.pre.version, function () {
          return getIpfs().version();
        }), opts),
        dns: (0, _postmsgRpc.expose)('ipfs.dns', (0, _prepost.pre)(opts.pre.dns, function () {
          var _getIpfs;

          return (_getIpfs = getIpfs()).dns.apply(_getIpfs, arguments);
        }), opts),
        block: (0, _block2.default)(getIpfs, opts),
        config: (0, _config2.default)(getIpfs, opts),
        dag: (0, _dag2.default)(getIpfs, opts),
        dht: (0, _dht2.default)(getIpfs, opts),
        files: (0, _files2.default)(getIpfs, opts),
        key: (0, _key2.default)(getIpfs, opts),
        object: (0, _object2.default)(getIpfs, opts),
        pin: (0, _pin2.default)(getIpfs, opts),
        pubsub: (0, _pubsub2.default)(getIpfs, opts),
        swarm: (0, _swarm2.default)(getIpfs, opts)
      };
    };

    function closeProxyServer(obj) {
      Object.keys(obj).forEach(function (k) {
        if (obj[k].close) {
          obj[k].close();
        } else {
          closeProxyServer(obj[k]);
        }
      });
    }