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

Commit

Permalink
Merge pull request #43 from ipfs/feat/version/api+cli+core+tests
Browse files Browse the repository at this point in the history
version
  • Loading branch information
daviddias committed Jan 8, 2016
2 parents fa727a8 + 258e892 commit 8bf3da8
Show file tree
Hide file tree
Showing 60 changed files with 272 additions and 173 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
js-ipfs
=======

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) ![Build Status](https://travis-ci.org/ipfs/js-ipfs.svg?style=flat-square)](https://travis-ci.org/ipfs/js-ipfs) ![](https://img.shields.io/badge/coverage-%3F-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/ipfs/js-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) ![Build Status](https://travis-ci.org/ipfs/js-ipfs.svg?style=flat-square)](https://travis-ci.org/ipfs/js-ipfs) ![](https://img.shields.io/badge/coverage-75%25-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/ipfs/js-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

> IPFS JavaScript implementation entry point and roadmap
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
"main": "src/index.js",
"scripts": {
"lint": "standard",
"coverage": "istanbul cover --print both -- _mocha tests/*-test.js",
"test": "mocha tests/*-test.js"
"coverage": "istanbul cover --print both -- _mocha tests/test-*/test-*.js",
"test": "mocha tests/test-*/test-*.js"
},
"pre-commit": [
"lint"
"lint",
"test"
],
"repository": {
"type": "git",
Expand All @@ -29,20 +30,19 @@
"homepage": "https://github.com/ipfs/js-ipfs#readme",
"devDependencies": {
"chai": "^3.4.1",
"ipfsd-ctl": "^0.6.1",
"istanbul": "^0.4.1",
"mocha": "^2.3.4",
"ncp": "^2.0.0",
"nexpect": "^0.5.0",
"pre-commit": "^1.1.2",
"rimraf": "^2.4.4",
"standard": "^5.3.1"
},
"dependencies": {
"hapi": "^11.1.4",
"ipfs-api": "^2.7.0",
"ipfs-repo": "^0.1.0",
"peer-id": "^0.4.0",
"peer-info": "^0.4.0",
"boom": "^3.1.1",
"debug": "^2.2.0",
"hapi": "^12.0.0",
"ipfs-repo": "^0.2.2",
"ronin": "^0.3.11"
}
}
6 changes: 4 additions & 2 deletions src/cli/bin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#! /usr/bin/env node

var ronin = require('ronin')
'use strict'

var cli = ronin(__dirname)
const ronin = require('ronin')

const cli = ronin(__dirname)

cli.run()

Expand Down
6 changes: 4 additions & 2 deletions src/cli/commands/add.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
6 changes: 4 additions & 2 deletions src/cli/commands/commands.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
17 changes: 14 additions & 3 deletions src/cli/commands/daemon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command
const httpAPI = require('../../http-api')
const debug = require('debug')
const log = debug('cli:daemon')
log.error = debug('cli:damon:error')

module.exports = Command.extend({
desc: '',
desc: 'Start a long-running daemon process',

run: function (name) {}
run: name => {
httpAPI.start((err) => {
if (err) { return log.error(err) }
log('daemon started')
})
}
})
6 changes: 4 additions & 2 deletions src/cli/commands/dns.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
4 changes: 2 additions & 2 deletions src/cli/commands/get.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var Command = require('ronin').Command
const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
17 changes: 9 additions & 8 deletions src/cli/commands/id.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var Command = require('ronin').Command
var IPFS = require('../../ipfs-core')
const Command = require('ronin').Command
const IPFS = require('../../ipfs-core')
const debug = require('debug')
const log = debug('cli:id')
log.error = debug('cli:id:error')

module.exports = Command.extend({
desc: 'Shows IPFS Node ID info',
Expand All @@ -11,12 +14,10 @@ module.exports = Command.extend({
}
},

run: function (name) {
var node = new IPFS()
node.id(function (err, id) {
if (err) {
return console.error(err)
}
run: name => {
const node = new IPFS()
node.id((err, id) => {
if (err) { return log.error(err) }
console.log(id)
})
}
Expand Down
11 changes: 4 additions & 7 deletions src/cli/commands/init.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
var Command = require('ronin').Command
// var help = require('../src/help-menu.js')
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: 'Initialize ipfs local configuration',

// help: help,

options: {
bits: {
type: 'number',
Expand All @@ -25,7 +24,5 @@ module.exports = Command.extend({
}
},

run: function (name) {
console.log('NA - https://github.com/ipfs/js-ipfs/tree/jsipfs#getting-jsipfs-ready')
}
run: name => {}
})
6 changes: 4 additions & 2 deletions src/cli/commands/ls.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
6 changes: 4 additions & 2 deletions src/cli/commands/mount.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
6 changes: 4 additions & 2 deletions src/cli/commands/ping.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
6 changes: 4 additions & 2 deletions src/cli/commands/refs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
6 changes: 4 additions & 2 deletions src/cli/commands/resolve.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
6 changes: 4 additions & 2 deletions src/cli/commands/update.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var Command = require('ronin').Command
'use strict'

const Command = require('ronin').Command

module.exports = Command.extend({
desc: '',

run: function (name) {}
run: name => {}
})
18 changes: 11 additions & 7 deletions src/cli/commands/version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
var Command = require('ronin').Command
var IPFS = require('../../ipfs-core')
'use strict'

const Command = require('ronin').Command
const IPFS = require('../../ipfs-core')
const debug = require('debug')
const log = debug('cli:version')
log.error = debug('cli:version:error')

module.exports = Command.extend({
desc: 'Shows IPFS version information',
Expand All @@ -20,12 +25,11 @@ module.exports = Command.extend({
}
},

run: function (name) {
run: (name) => {
var node = new IPFS()
node.version(function (err, version) {
if (err) {
return console.error(err)
}
node.version((err, version) => {
if (err) { return log.error(err) }

console.log(version)
})
}
Expand Down
40 changes: 40 additions & 0 deletions src/http-api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict'

const Hapi = require('hapi')
const IPFS = require('../ipfs-core')
const debug = require('debug')
const log = debug('api')
log.error = debug('api:error')

exports = module.exports

exports.start = callback => {
// start IPFS and exports.ipfs = new IPFS()

exports.ipfs = new IPFS()

var server = exports.server = new Hapi.Server({
connections: {
routes: {
cors: true
}
}
})

server.connection({
port: 9000
})

// load routes
require('./routes/version.js')

server.start(err => {
if (err) { return callback(err) }
log('server started: ' + server.info.uri)
callback()
})
}

exports.stop = () => {

}
1 change: 1 addition & 0 deletions src/http-api/resources/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.version = require('./version')
14 changes: 14 additions & 0 deletions src/http-api/resources/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

const ipfs = require('./../index.js').ipfs
const boom = require('boom')

exports = module.exports

exports.get = (request, reply) => {
ipfs.version((err, version) => {
if (err) { return reply(boom.badRequest(err)) }
return reply(version)
})
}

10 changes: 10 additions & 0 deletions src/http-api/routes/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'

const server = require('./../index.js').server
const resources = require('./../resources')

server.route({
method: 'GET',
path: '/api/v0/version',
handler: resources.version.get
})
4 changes: 3 additions & 1 deletion src/ipfs-core/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var os = require('os')
'use strict'

const os = require('os')

exports = module.exports

Expand Down
Loading

0 comments on commit 8bf3da8

Please sign in to comment.