Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit ed5e9ef

Browse files
author
Alan Shaw
authored
refactor: convert version API to async/await (#2679)
1 parent 20cbd6d commit ed5e9ef

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

src/core/components/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ exports.init = require('./init')
1212
exports.ping = require('./ping')
1313
exports.start = require('./start')
1414
exports.stop = require('./stop')
15+
exports.version = require('./version')
1516

1617
exports.legacy = { // TODO: these will be removed as the new API is completed
1718
dag: require('./dag'),

src/core/components/init.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ function createApi ({
302302
config: Commands.config({ repo }),
303303
id: Commands.id({ peerInfo }),
304304
init: () => { throw new AlreadyInitializedError() },
305-
start
305+
start,
306+
version: Commands.version({ repo })
306307
}
307308

308309
return api

src/core/components/start.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ function createApi ({
144144
? Commands.pubsub({ libp2p })
145145
: () => { throw new NotEnabledError('pubsub not enabled') },
146146
start: () => apiManager.api,
147-
stop
147+
stop,
148+
version: Commands.version({ repo })
148149
}
149150

150151
return api

src/core/components/stop.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ function createApi ({
102102
id: Commands.id({ peerInfo }),
103103
init: () => { throw new AlreadyInitializedError() },
104104
start,
105-
stop: () => apiManager.api
105+
stop: () => apiManager.api,
106+
version: Commands.version({ repo })
106107
}
107108

108109
return api

src/core/components/version.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
'use strict'
22

33
const pkg = require('../../../package.json')
4-
const callbackify = require('callbackify')
54

65
// TODO add the commit hash of the current ipfs version to the response.
7-
module.exports = function version (self) {
8-
return callbackify(async () => {
9-
const repoVersion = await self.repo.version()
6+
module.exports = ({ repo }) => {
7+
return async function version () {
8+
const repoVersion = await repo.version()
109

1110
return {
1211
version: pkg.version,
1312
repo: repoVersion,
1413
commit: ''
1514
}
16-
})
15+
}
1716
}

0 commit comments

Comments
 (0)