mirror of
https://github.com/amark/gun.git
synced 2025-06-13 17:46:39 +00:00
commit
ed09e548fe
4
gun.js
4
gun.js
@ -392,7 +392,9 @@
|
|||||||
Gun.is.node.state.ify([vertex, change, node], field, val);
|
Gun.is.node.state.ify([vertex, change, node], field, val);
|
||||||
}
|
}
|
||||||
emit({soul: soul, field: field, value: val, state: state, change: change});
|
emit({soul: soul, field: field, value: val, state: state, change: change});
|
||||||
}, function(vertex, field, val){})(function(){
|
}, function(vertex, field, val, state){
|
||||||
|
Gun.on('deferred').emit(gun, {soul: soul, field: field, value: val, state: state, change: node});
|
||||||
|
})(function(){
|
||||||
emit({soul: soul, change: node});
|
emit({soul: soul, change: node});
|
||||||
if(opt.soul){ opt.soul(soul) }
|
if(opt.soul){ opt.soul(soul) }
|
||||||
if(!(ctx.count -= 1)){ ctx.cb() }
|
if(!(ctx.count -= 1)){ ctx.cb() }
|
||||||
|
12
lib/wsp.js
12
lib/wsp.js
@ -126,7 +126,7 @@
|
|||||||
tran.get = function(req, cb){
|
tran.get = function(req, cb){
|
||||||
var key = req.url.key
|
var key = req.url.key
|
||||||
, reply = {headers: {'Content-Type': tran.json, rid: req.headers.id, id: gun.wsp.msg()}};
|
, reply = {headers: {'Content-Type': tran.json, rid: req.headers.id, id: gun.wsp.msg()}};
|
||||||
//console.log(req);
|
//Gun.log(req);
|
||||||
// NTS HACK! SHOULD BE ITS OWN ISOLATED MODULE! //
|
// NTS HACK! SHOULD BE ITS OWN ISOLATED MODULE! //
|
||||||
if(req && req.url && req.url.pathname && req.url.pathname.indexOf('gun.nts') >= 0){
|
if(req && req.url && req.url.pathname && req.url.pathname.indexOf('gun.nts') >= 0){
|
||||||
return cb({headers: reply.headers, body: {time: Gun.time.is() }});
|
return cb({headers: reply.headers, body: {time: Gun.time.is() }});
|
||||||
@ -138,13 +138,13 @@
|
|||||||
cb({headers: reply.headers, body: (err? (err.err? err : {err: err || "Unknown error."}) : list || null ) })
|
cb({headers: reply.headers, body: (err? (err.err? err : {err: err || "Unknown error."}) : list || null ) })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log("GET!", req);
|
//Gun.log("GET!", req);
|
||||||
key = req.body;
|
key = req.body;
|
||||||
console.log("tran.get", key);
|
//Gun.log("tran.get", key);
|
||||||
var opt = {key: false};
|
var opt = {key: false};
|
||||||
//gun.get(key, function(err, node){
|
//gun.get(key, function(err, node){
|
||||||
(gun.__.opt.wire.get||function(key, cb){cb(null,null)})(key, function(err, node){
|
(gun.__.opt.wire.get||function(key, cb){cb(null,null)})(key, function(err, node){
|
||||||
//console.log("tran.get", key, "<---", err, node);
|
//Gun.log("tran.get", key, "<---", err, node);
|
||||||
reply.headers.id = gun.wsp.msg();
|
reply.headers.id = gun.wsp.msg();
|
||||||
if(err || !node){
|
if(err || !node){
|
||||||
if(opt.on && opt.on.off){ opt.on.off() }
|
if(opt.on && opt.on.off){ opt.on.off() }
|
||||||
@ -182,7 +182,7 @@
|
|||||||
// This will give you much more fine-grain control over security, transactions, and what not.
|
// This will give you much more fine-grain control over security, transactions, and what not.
|
||||||
var reply = {headers: {'Content-Type': tran.json, rid: req.headers.id, id: gun.wsp.msg()}};
|
var reply = {headers: {'Content-Type': tran.json, rid: req.headers.id, id: gun.wsp.msg()}};
|
||||||
if(!req.body){ return cb({headers: reply.headers, body: {err: "No body"}}) }
|
if(!req.body){ return cb({headers: reply.headers, body: {err: "No body"}}) }
|
||||||
//console.log("\n\ntran.put ----------------->", req.body);
|
//Gun.log("\n\ntran.put ----------------->", req.body);
|
||||||
if(Gun.is.graph(req.body)){
|
if(Gun.is.graph(req.body)){
|
||||||
if(req.err = Gun.union(gun, req.body, function(err, ctx){ // TODO: BUG? Probably should give me ctx.graph
|
if(req.err = Gun.union(gun, req.body, function(err, ctx){ // TODO: BUG? Probably should give me ctx.graph
|
||||||
if(err){ return cb({headers: reply.headers, body: {err: err || "Union failed."}}) }
|
if(err){ return cb({headers: reply.headers, body: {err: err || "Union failed."}}) }
|
||||||
@ -193,7 +193,7 @@
|
|||||||
(gun.__.opt.wire.put || function(g,cb){cb("No save.")})(ctx.graph, function(err, ok){
|
(gun.__.opt.wire.put || function(g,cb){cb("No save.")})(ctx.graph, function(err, ok){
|
||||||
if(err){ return cb({headers: reply.headers, body: {err: err || "Failed."}}) } // TODO: err should already be an error object?
|
if(err){ return cb({headers: reply.headers, body: {err: err || "Failed."}}) } // TODO: err should already be an error object?
|
||||||
cb({headers: reply.headers, body: {ok: ok || "Persisted."}});
|
cb({headers: reply.headers, body: {ok: ok || "Persisted."}});
|
||||||
//console.log("tran.put <------------------------", ok);
|
//Gun.log("tran.put <------------------------", ok);
|
||||||
});
|
});
|
||||||
}).err){ cb({headers: reply.headers, body: {err: req.err || "Union failed."}}) }
|
}).err){ cb({headers: reply.headers, body: {err: req.err || "Union failed."}}) }
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gun",
|
"name": "gun",
|
||||||
"version": "0.3.7",
|
"version": "0.3.8",
|
||||||
"description": "Graph engine",
|
"description": "Graph engine",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user