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

Commit

Permalink
Stubbed out resources and routes
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLitt committed Mar 10, 2016
1 parent a419f04 commit 0abed00
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 3 deletions.
39 changes: 39 additions & 0 deletions src/http-api/resources/block.js
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)
})
}
51 changes: 48 additions & 3 deletions src/http-api/routes/block.js
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.
}
}
}
})

0 comments on commit 0abed00

Please sign in to comment.