# All files / server index.js

85.71% Statements 24/28
75% Branches 6/8
42.86% Functions 3/7
85.19% Lines 23/27

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

    1x

    1x
    1x
    65x

    1x

    14x
    79x
    66x

    13x

     import { expose } from 'postmsg-rpc'
    import { pre } from 'prepost'
    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 createObject from './object'
    import createPin from './pin'
    import createPubsub from './pubsub'
    import createRepo from './repo'
    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 {
        id: expose('ipfs.id', pre(
          opts.pre('id'),
          () => getIpfs().id()
        ), opts),
        version: expose('ipfs.version', pre(
          opts.pre('version'),
          () => getIpfs().version()
        ), opts),
        dns: expose('ipfs.dns', pre(
          opts.pre('dns'),
          (...args) => getIpfs().dns(...args)
        ), opts),
        block: createBlock(getIpfs, opts),
        config: createConfig(getIpfs, opts),
        dag: createDag(getIpfs, opts),
        dht: createDht(getIpfs, opts),
        files: createFiles(getIpfs, opts),
        key: createKey(getIpfs, opts),
        ls: createLs(getIpfs, opts),
        object: createObject(getIpfs, opts),
        pin: createPin(getIpfs, opts),
        pubsub: createPubsub(getIpfs, opts),
        repo: createRepo(getIpfs, opts),
        swarm: createSwarm(getIpfs, opts),
        stop: expose('ipfs.stop', pre(
          opts.pre('stop'),
          () => getIpfs().stop()
        ), opts)
      }
    }

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