This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a419f04
commit 0abed00
Showing
2 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict' | ||
|
||
const ipfs = require('./../index.js').ipfs | ||
// const debug = require('debug') | ||
// const get = require('lodash.get') | ||
// const set = require('lodash.set') | ||
// const log = debug('http-api:config') | ||
// log.error = debug('http-api:config:error') | ||
// const multipart = require('ipfs-multipart') | ||
|
||
exports = module.exports | ||
|
||
exports.get = (request, reply) => { | ||
ipfs.block.get((multihash, callback) => { | ||
// parseargs to make sure it is a Multihash | ||
return reply(callback) | ||
}) | ||
} | ||
|
||
exports.put = (request, reply) => { | ||
ipfs.block.put((multihash, callback) => { | ||
// parseArgs to make sure it is a block | ||
return reply(callback) | ||
}) | ||
} | ||
|
||
exports.del = (request, reply) => { | ||
ipfs.block.del((multihash, callback) => { | ||
// parseargs to make sure it is a Multihash | ||
return reply(callback) | ||
}) | ||
} | ||
|
||
exports.stat = (request, reply) => { | ||
ipfs.block.stat((multihash, callback) => { | ||
// parseargs to make sure it is a Multihash | ||
return reply(callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,55 @@ | ||
const api = require('./../index.js').server.select('API') | ||
const resources = require('./../resources') | ||
const Joi = require('joi') | ||
|
||
// TODO | ||
api.route({ | ||
method: 'GET', | ||
path: '/api/v0/block/get/{arg?}', | ||
handler: resources.block.get, | ||
config: { | ||
validate: { | ||
query: { | ||
arg: Joi.string().required() // The base58 multihash of an existing block to get. | ||
} | ||
} | ||
} | ||
}) | ||
|
||
api.route({ | ||
method: 'POST', | ||
path: '/api/v0/block/put/{arg?}', | ||
handler: resources.block.put, | ||
config: { | ||
validate: { | ||
query: { | ||
arg: Joi.string().required() // The data to be stored as an IPFS block. | ||
} | ||
} | ||
} | ||
}) | ||
|
||
api.route({ | ||
method: 'DELETE', | ||
path: '/api/v0/block/del/{arg?}', | ||
handler: resources.block.del, | ||
config: { | ||
validate: { | ||
query: { | ||
arg: Joi.string().required() // The base58 multihash of the IPFS block to be removed. | ||
} | ||
} | ||
} | ||
}) | ||
|
||
api.route({ | ||
method: 'GET', | ||
path: '/api/v0/block', | ||
handler: resources.block | ||
path: '/api/v0/block/stat/{arg?}', | ||
handler: resources.block.stat, | ||
config: { | ||
validate: { | ||
query: { | ||
arg: Joi.string().required() // The base58 multihash of an existing block to get. | ||
} | ||
} | ||
} | ||
}) |