From c8fe8ae00ca4810b5c8142f8f800a247f2fd4bed Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Wed, 3 Feb 2016 12:07:41 -0800 Subject: [PATCH] SPAM --- gun.js | 2 +- lib/file.js | 1 + lib/wsp.js | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gun.js b/gun.js index 12840b9b..c2a7d28d 100644 --- a/gun.js +++ b/gun.js @@ -1,5 +1,5 @@ ;(function(){ - //module.exports = require('../gun4');return; + module.exports = require('../gun4');return; function Gun(o){ var gun = this; if(!Gun.is(gun)){ return new Gun(o) } diff --git a/lib/file.js b/lib/file.js index d16e0601..d272f68e 100644 --- a/lib/file.js +++ b/lib/file.js @@ -40,6 +40,7 @@ Gun.on('opt').event(function(gun, opts) { get: function get(lex, cb, o){ var node, soul = lex[Gun._.soul]; node = all.nodes[soul]; + console.log("FILE.GET", lex, soul, node); if(!node){ return cb(null) } cb(null, node); node = Gun.is.node.soul.ify({}, soul); diff --git a/lib/wsp.js b/lib/wsp.js index df0b08c7..8ca139aa 100644 --- a/lib/wsp.js +++ b/lib/wsp.js @@ -97,15 +97,21 @@ // except for the ones that are listed in the message as having already been sending to. // all states, implemented with GET, are replied to the source that asked for it. function tran(req, cb){ + //console.log("REQUEST", req); + if(Gun.text.is(req.body)){ + if('?' === req.body.slice(-1)){ + req.lex = Gun.get.wire(req.body); + delete req.body; + } + } req.method = req.body? 'put' : 'get'; // put or get is based on whether there is a body or not req.key = req.url.pathname.replace(gun.wsp.regex,'').replace(/^\//i,'') || ''; - console.log("REQUEST", req); if('get' == req.method){ return tran.get(req, cb) } if('put' == req.method || 'post' == req.method){ return tran.put(req, cb) } cb({body: {hello: 'world'}}); } tran.get = function(req, cb){ - var key = req.key + var key = req.lex || req.key , reply = {headers: {'Content-Type': tran.json}}; //console.log(req); // NTS HACK! SHOULD BE ITS OWN ISOLATED MODULE! // @@ -137,7 +143,7 @@ //console.log("tran.get", key, "<---", err, node); if(err || !node){ if(opt.on && opt.on.off){ opt.on.off() } - return cb({headers: reply.headers, body: (err? (err.err? err : {err: err || "Unknown error."}) : null)}); + return cb({headers: reply.headers, body: (err? (err.err? err : {err: err || "Unknown error."}) : undefined)}); } if(Gun.obj.empty(node)){ if(opt.on && opt.on.off){ opt.on.off() }