# All files / server index.js

90.32% Statements 28/31
75% Branches 6/8
57.14% Functions 4/7
90% Lines 27/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    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
    711x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x

    1x

    1x
    1x
    69x

    1x

    1x

    17x
    87x
    71x

    16x

     import { expose } from 'postmsg-rpc'
    import { pre } from 'prepost'
    import createBitswap from './bitswap'
    import createBlock from './block'
    import createConfig from './config'
    import createDag from './dag'
    import createDht from './dht'
    import createFiles from './files'
    import createKey from './key'
    import createLs from './ls'
    import createName from './name'
    import createObject from './object'
    import createPin from './pin'
    import createPubsub from './pubsub'
    import createRepo from './repo'
    import createStats from './stats'
    import createSwarm from './swarm'

    export default (getIpfs, opts) => {
      opts = opts || {}

      Eif (typeof opts.pre !== 'function') {
        const preObj = opts.pre || {}
        opts.pre = (fnName) => preObj[fnName]
      }

      return {
        bitswap: createBitswap(getIpfs, opts),
        block: createBlock(getIpfs, opts),
        config: createConfig(getIpfs, opts),
        dag: createDag(getIpfs, opts),
        dht: createDht(getIpfs, opts),
        dns: expose('ipfs.dns', pre(
          opts.pre('dns'),
          (...args) => getIpfs().dns(...args)
        ), opts),
        files: createFiles(getIpfs, opts),
        id: expose('ipfs.id', pre(
          opts.pre('id'),
          () => getIpfs().id()
        ), opts),
        key: createKey(getIpfs, opts),
        ls: createLs(getIpfs, opts),
        name: createName(getIpfs, opts),
        object: createObject(getIpfs, opts),
        pin: createPin(getIpfs, opts),
        pubsub: createPubsub(getIpfs, opts),
        repo: createRepo(getIpfs, opts),
        stats: createStats(getIpfs, opts),
        stop: expose('ipfs.stop', pre(
          opts.pre('stop'),
          () => getIpfs().stop()
        ), opts),
        swarm: createSwarm(getIpfs, opts),
        version: expose('ipfs.version', pre(
          opts.pre('version'),
          () => getIpfs().version()
        ), opts)
      }
    }

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