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

Commit 26459f4

Browse files
RichardLittfbaiodias
authored andcommitted
Stubbed out resources and routes
1 parent 94f26f0 commit 26459f4

File tree

2 files changed

+88
-3
lines changed

2 files changed

+88
-3
lines changed

src/http-api/resources/block.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict'
2+
3+
const ipfs = require('./../index.js').ipfs
4+
// const debug = require('debug')
5+
// const get = require('lodash.get')
6+
// const set = require('lodash.set')
7+
// const log = debug('http-api:config')
8+
// log.error = debug('http-api:config:error')
9+
// const multipart = require('ipfs-multipart')
10+
11+
exports = module.exports
12+
13+
exports.get = (request, reply) => {
14+
ipfs.block.get((multihash, callback) => {
15+
// parseargs to make sure it is a Multihash
16+
return reply(callback)
17+
})
18+
}
19+
20+
exports.put = (request, reply) => {
21+
ipfs.block.put((multihash, callback) => {
22+
// parseArgs to make sure it is a block
23+
return reply(callback)
24+
})
25+
}
26+
27+
exports.del = (request, reply) => {
28+
ipfs.block.del((multihash, callback) => {
29+
// parseargs to make sure it is a Multihash
30+
return reply(callback)
31+
})
32+
}
33+
34+
exports.stat = (request, reply) => {
35+
ipfs.block.stat((multihash, callback) => {
36+
// parseargs to make sure it is a Multihash
37+
return reply(callback)
38+
})
39+
}

src/http-api/routes/block.js

+49-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,58 @@
11
const resources = require('./../resources')
2+
const Joi = require('joi')
23

3-
// TODO
44
module.exports = (server) => {
55
const api = server.select('API')
66

77
api.route({
88
method: 'GET',
9-
path: '/api/v0/block',
10-
handler: resources.block
9+
path: '/api/v0/block/get/{arg?}',
10+
handler: resources.block.get,
11+
config: {
12+
validate: {
13+
query: {
14+
arg: Joi.string().required() // The base58 multihash of an existing block to get.
15+
}
16+
}
17+
}
18+
})
19+
20+
api.route({
21+
method: 'POST',
22+
path: '/api/v0/block/put/{arg?}',
23+
handler: resources.block.put,
24+
config: {
25+
validate: {
26+
query: {
27+
arg: Joi.string().required() // The data to be stored as an IPFS block.
28+
}
29+
}
30+
}
31+
})
32+
33+
api.route({
34+
method: 'DELETE',
35+
path: '/api/v0/block/del/{arg?}',
36+
handler: resources.block.del,
37+
config: {
38+
validate: {
39+
query: {
40+
arg: Joi.string().required() // The base58 multihash of the IPFS block to be removed.
41+
}
42+
}
43+
}
44+
})
45+
46+
api.route({
47+
method: 'GET',
48+
path: '/api/v0/block/stat/{arg?}',
49+
handler: resources.block.stat,
50+
config: {
51+
validate: {
52+
query: {
53+
arg: Joi.string().required() // The base58 multihash of an existing block to get.
54+
}
55+
}
56+
}
1157
})
1258
}

0 commit comments

Comments
 (0)