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

Commit

Permalink
feat: implement REPO.Version on HTTP, CLI and CORE
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jan 30, 2018
1 parent 49aa033 commit 5ef74f5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/cli/commands/repo/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ module.exports = {
builder: {},

handler (argv) {
argv.ipfs.repo.version(function (err, version) {
argv.ipfs.repo.version((err, data) => {
if (err) {
throw err
}
print(version)

print(data.Version)
})
}
}
19 changes: 19 additions & 0 deletions src/http/api/resources/repo.js
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
'use strict'

exports = module.exports

exports.version = (request, reply) => {
const ipfs = request.server.app.ipfs

ipfs.repo.version((err, version) => {
if (err) {
return reply({
Message: err.toString(),
Code: 0
}).code(500)
}

reply({
Version: version
})
})
}
2 changes: 1 addition & 1 deletion src/http/api/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = (server) => {
require('./bootstrap')(server)
require('./block')(server)
require('./object')(server)
// require('./repo')(server)
require('./repo')(server)
require('./config')(server)
require('./swarm')(server)
require('./bitswap')(server)
Expand Down
9 changes: 6 additions & 3 deletions src/http/api/routes/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

const resources = require('./../resources')

// TODO
module.exports = (server) => {
const api = server.select('API')

api.route({
method: '*',
path: '/api/v0/repo',
handler: resources.repo
path: '/api/v0/repo/version',
config: {
handler: resources.repo.version
}
})

// TODO: implement the missing spec https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REPO.md
}

0 comments on commit 5ef74f5

Please sign in to comment.