Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 33729d1

Browse files
docs(api): initial baseline setup
1 parent 802d98d commit 33729d1

33 files changed

+538
-75
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
test/setup/tmp-disposable-nodes-addrs.json
44
dist
55
coverage
6+
docs

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
coverage
44

55
test
6+
docs

documentation.yml

Whitespace-only changes.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"release-minor": "gulp release --type minor",
2020
"release-major": "gulp release --type major",
2121
"coverage": "gulp coverage",
22-
"coverage-publish": "aegir-coverage publish"
22+
"coverage-publish": "aegir-coverage publish",
23+
"docs": "aegir-docs"
2324
},
2425
"dependencies": {
2526
"async": "^2.1.4",

src/api/add.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ const addToDagNodesTransform = require('../add-to-dagnode-transform')
55
const promisify = require('promisify-es6')
66

77
module.exports = (send) => {
8+
/**
9+
* Add content to IPFS.
10+
*
11+
* @alias add
12+
* @method
13+
* @param {(Buffer|Stream|Array)} files - The content to add.
14+
* @param {function=} callback
15+
* @returns {Promise}
16+
*
17+
* @memberof Api#
18+
*
19+
* @example
20+
* api.add(new Buffer('hello world')).then((res) => {
21+
* console.log('saved with hash %s', res.hash)
22+
* })
23+
*
24+
*/
825
return promisify((files, callback) => {
926
const good = Buffer.isBuffer(files) ||
1027
isStream.isReadable(files) ||

src/api/bitswap.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,48 @@ const promisify = require('promisify-es6')
44

55
module.exports = (send) => {
66
return {
7+
/**
8+
* Show blocks currently on the wantlist.
9+
*
10+
* @alias bitswap.wantlist
11+
* @method
12+
* @param {Function} [callback]
13+
*
14+
* @returns {Promise}
15+
* @memberof Api#
16+
*/
717
wantlist: promisify((callback) => {
818
send({
919
path: 'bitswap/wantlist'
1020
}, callback)
1121
}),
22+
/**
23+
* Show some diagnostic information on the bitswap agent.
24+
*
25+
* @alias bitswap.stat
26+
* @method
27+
* @param {Function} [callback]
28+
*
29+
* @returns {Promise}
30+
* @memberof Api#
31+
*/
1232
stat: promisify((callback) => {
1333
send({
1434
path: 'bitswap/stat'
1535
}, callback)
1636
}),
37+
/**
38+
* Remove a given block from your wantlist.
39+
*
40+
* @alias bitswap.unwant
41+
* @method
42+
* @param {*} args
43+
* @param {Object} opts
44+
* @param {Function} [callback]
45+
*
46+
* @returns {Promise}
47+
* @memberof Api#
48+
*/
1749
unwant: promisify((args, opts, callback) => {
1850
if (typeof (opts) === 'function') {
1951
callback = opts

src/api/block.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ const CID = require('cids')
88

99
module.exports = (send) => {
1010
return {
11+
/**
12+
* @alias block.get
13+
* @method
14+
* @returns {Promise|undefined}
15+
* @memberof Api#
16+
*/
1117
get: promisify((args, opts, callback) => {
1218
// TODO this needs to be adjusted with the new go-ipfs http-api
1319
if (args && CID.isCID(args)) {
@@ -38,6 +44,13 @@ module.exports = (send) => {
3844
}
3945
})
4046
}),
47+
48+
/**
49+
* @alias block.stat
50+
* @method
51+
* @returns {Promise|undefined}
52+
* @memberof Api#
53+
*/
4154
stat: promisify((args, opts, callback) => {
4255
// TODO this needs to be adjusted with the new go-ipfs http-api
4356
if (args && CID.isCID(args)) {
@@ -62,6 +75,13 @@ module.exports = (send) => {
6275
})
6376
})
6477
}),
78+
79+
/**
80+
* @alias block.put
81+
* @method
82+
* @returns {Promise|undefined}
83+
* @memberof Api#
84+
*/
6585
put: promisify((block, cid, callback) => {
6686
// TODO this needs to be adjusted with the new go-ipfs http-api
6787
if (typeof cid === 'function') {

src/api/bootstrap.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const promisify = require('promisify-es6')
44

55
module.exports = (send) => {
66
return {
7+
/**
8+
* @alias bootstrap.add
9+
* @method
10+
* @returns {Promise|undefined}
11+
* @memberof Api#
12+
*/
713
add: promisify((args, opts, callback) => {
814
if (typeof opts === 'function' &&
915
!callback) {
@@ -30,6 +36,13 @@ module.exports = (send) => {
3036
qs: opts
3137
}, callback)
3238
}),
39+
40+
/**
41+
* @alias bootstrap.rm
42+
* @method
43+
* @returns {Promise|undefined}
44+
* @memberof Api#
45+
*/
3346
rm: promisify((args, opts, callback) => {
3447
if (typeof opts === 'function' &&
3548
!callback) {
@@ -56,6 +69,13 @@ module.exports = (send) => {
5669
qs: opts
5770
}, callback)
5871
}),
72+
73+
/**
74+
* @alias bootstrap.list
75+
* @method
76+
* @returns {Promise|undefined}
77+
* @memberof Api#
78+
*/
5979
list: promisify((opts, callback) => {
6080
if (typeof (opts) === 'function') {
6181
callback = opts

src/api/cat.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const promisify = require('promisify-es6')
44
const cleanMultihash = require('../clean-multihash')
55

66
module.exports = (send) => {
7+
/**
8+
* @alias cat
9+
* @method
10+
* @returns {Promise|undefined}
11+
* @memberof Api#
12+
*/
713
return promisify((hash, opts, callback) => {
814
if (typeof opts === 'function') {
915
callback = opts

src/api/commands.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
const promisify = require('promisify-es6')
44

55
module.exports = (send) => {
6+
/**
7+
* @alias commands
8+
* @method
9+
* @returns {Promise|undefined}
10+
* @memberof Api#
11+
*/
612
return promisify((callback) => {
713
send({
814
path: 'commands'

src/api/config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ const promisify = require('promisify-es6')
55

66
module.exports = (send) => {
77
return {
8+
/**
9+
* @alias config.get
10+
* @method
11+
* @returns {Promise|undefined}
12+
* @memberof Api#
13+
*/
814
get: promisify((key, callback) => {
915
if (typeof key === 'function') {
1016
callback = key
@@ -30,6 +36,12 @@ module.exports = (send) => {
3036
callback(null, response.Value)
3137
})
3238
}),
39+
/**
40+
* @alias config.set
41+
* @method
42+
* @returns {Promise|undefined}
43+
* @memberof Api#
44+
*/
3345
set: promisify((key, value, opts, callback) => {
3446
if (typeof opts === 'function') {
3547
callback = opts
@@ -63,6 +75,12 @@ module.exports = (send) => {
6375
buffer: true
6476
}, callback)
6577
}),
78+
/**
79+
* @alias config.replace
80+
* @method
81+
* @returns {Promise|undefined}
82+
* @memberof Api#
83+
*/
6684
replace: promisify((config, callback) => {
6785
if (typeof config === 'object') {
6886
config = streamifier.createReadStream(new Buffer(JSON.stringify(config)))

src/api/create-add-stream.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ const promisify = require('promisify-es6')
77
module.exports = (send) => {
88
const add = addCmd(send)
99

10+
/**
11+
* @alias createAddStream
12+
* @method
13+
* @returns {Promise|undefined}
14+
* @memberof Api#
15+
*/
1016
return promisify((callback) => {
1117
const tuples = []
1218

src/api/dht.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const promisify = require('promisify-es6')
44

55
module.exports = (send) => {
66
return {
7+
/**
8+
* @alias dht.findprovs
9+
* @method
10+
* @returns {Promise|undefined}
11+
* @memberof Api#
12+
*/
713
findprovs: promisify((args, opts, callback) => {
814
if (typeof opts === 'function' &&
915
!callback) {
@@ -25,6 +31,13 @@ module.exports = (send) => {
2531
qs: opts
2632
}, callback)
2733
}),
34+
35+
/**
36+
* @alias dht.get
37+
* @method
38+
* @returns {Promise|undefined}
39+
* @memberof Api#
40+
*/
2841
get: promisify((key, opts, callback) => {
2942
if (typeof opts === 'function' &&
3043
!callback) {
@@ -70,6 +83,13 @@ module.exports = (send) => {
7083
qs: opts
7184
}, handleResult.bind(null, callback))
7285
}),
86+
87+
/**
88+
* @alias dht.put
89+
* @method
90+
* @returns {Promise|undefined}
91+
* @memberof Api#
92+
*/
7393
put: promisify((key, value, opts, callback) => {
7494
if (typeof opts === 'function' &&
7595
!callback) {

src/api/diag.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const promisify = require('promisify-es6')
44

55
module.exports = (send) => {
66
return {
7+
/**
8+
* @alias diag.net
9+
* @method
10+
* @returns {Promise|undefined}
11+
* @memberof Api#
12+
*/
713
net: promisify((opts, callback) => {
814
if (typeof (opts) === 'function') {
915
callback = opts
@@ -15,6 +21,13 @@ module.exports = (send) => {
1521
qs: opts
1622
}, callback)
1723
}),
24+
25+
/**
26+
* @alias diag.sys
27+
* @method
28+
* @returns {Promise|undefined}
29+
* @memberof Api#
30+
*/
1831
sys: promisify((opts, callback) => {
1932
if (typeof (opts) === 'function') {
2033
callback = opts
@@ -26,6 +39,13 @@ module.exports = (send) => {
2639
qs: opts
2740
}, callback)
2841
}),
42+
43+
/**
44+
* @alias diag.cmds
45+
* @method
46+
* @returns {Promise|undefined}
47+
* @memberof Api#
48+
*/
2949
cmds: promisify((opts, callback) => {
3050
if (typeof (opts) === 'function') {
3151
callback = opts

0 commit comments

Comments
 (0)