This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 2 files changed +88
-3
lines changed
2 files changed +88
-3
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 1
1
const resources = require ( './../resources' )
2
+ const Joi = require ( 'joi' )
2
3
3
- // TODO
4
4
module . exports = ( server ) => {
5
5
const api = server . select ( 'API' )
6
6
7
7
api . route ( {
8
8
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
+ }
11
57
} )
12
58
}
You can’t perform that action at this time.
0 commit comments