appbase-js
Advanced tools
Comparing version 0.10.6 to 0.10.7
{ | ||
"name": "appbase-js", | ||
"version": "0.10.6", | ||
"version": "0.10.7", | ||
"homepage": "https://github.com/appbaseio/appbase-js", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -54,5 +54,5 @@ 'use strict'; | ||
if (parsedUrl.protocol === 'https:') { | ||
this.ws = new betterWs('wss://' + parsedUrl.host); | ||
this.ws = new betterWs('wss://' + parsedUrl.host + '/' + this.appname); | ||
} else { | ||
this.ws = new betterWs('ws://' + parsedUrl.host); | ||
this.ws = new betterWs('ws://' + parsedUrl.host + '/' + this.appname); | ||
} | ||
@@ -59,0 +59,0 @@ |
@@ -22,4 +22,4 @@ var ajs = Npm.require('appbase-js') | ||
client.getStream = this.reactiveVarReturn.bind(this)("get", "getStream") | ||
client.searchStream = this.reactiveVarReturn.bind(this)("search", "searchStream") | ||
client.getStream = this.ajsClient.getStream | ||
client.searchStream = this.ajsClient.searchStream | ||
@@ -42,18 +42,2 @@ return client | ||
}).bind(this) | ||
} | ||
Appbase.prototype.reactiveVarReturn = function reactiveVarReturn(name, streamingName) { | ||
return (function(...args) { | ||
var rvar = new ReactiveVar(this.varReturn.bind(this)(name)(...args)) | ||
this.ajsClient[streamingName](...args) | ||
.on('data', Meteor.bindEnvironment(function(d) { | ||
rvar.set(d) | ||
console.log('b', rvar.get()) | ||
})) | ||
.on('error', Meteor.bindEnvironment(function(e) { | ||
rvar.set(e) | ||
})) | ||
return rvar | ||
}).bind(this) | ||
} |
Package.describe({ | ||
name: 'appbaseio:appbase', | ||
version: '0.10.5', | ||
version: '0.10.7', | ||
summary: 'Appbase.io streaming client library for Meteor', | ||
git: 'https://github.com/appbaseio/appbase-js', | ||
documentation: 'README.md' | ||
documentation: 'meteor/README.md' | ||
}); | ||
Npm.depends({ | ||
"appbase-js": "0.10.6", | ||
"fibers": "1.0.8" | ||
"appbase-js": "0.10.7" | ||
}); | ||
@@ -20,5 +19,6 @@ | ||
api.addFiles('meteor/appbase.js', 'server'); | ||
//api.addFiles('browser/appbase.js', ['client']); | ||
api.addFiles('browser/appbase.min.js', 'client'); | ||
api.export('Appbase', 'server'); | ||
api.export('appbase', 'client'); | ||
}); | ||
@@ -30,3 +30,4 @@ | ||
api.use('appbaseio:appbase'); | ||
api.addFiles('meteor/appbase-tests.js', 'server'); | ||
api.addFiles('meteor/appbase-server-tests.js', 'server'); | ||
api.addFiles('meteor/appbase-client-tests.js', 'client'); | ||
}); |
{ | ||
"name": "appbase-js", | ||
"version": "0.10.6", | ||
"version": "0.10.7", | ||
"description": "Appbase.io streaming client lib for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "dist/appbase.js", |
@@ -52,5 +52,5 @@ var URL = require('url') | ||
if (parsedUrl.protocol === 'https:') { | ||
this.ws = new betterWs('wss://' + parsedUrl.host) | ||
this.ws = new betterWs('wss://' + parsedUrl.host + '/' + this.appname) | ||
} else { | ||
this.ws = new betterWs('ws://' + parsedUrl.host) | ||
this.ws = new betterWs('ws://' + parsedUrl.host + '/' + this.appname) | ||
} | ||
@@ -57,0 +57,0 @@ |
@@ -41,12 +41,14 @@ var assert = require('assert') | ||
streamingClient.index({ | ||
type: 'tweet', | ||
id: '1', | ||
body: tweet | ||
}).on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
setTimeout(function() { | ||
streamingClient.index({ | ||
type: 'tweet', | ||
id: '1', | ||
body: tweet | ||
}).on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
}, 2000) | ||
}).on('error', function(err) { | ||
@@ -83,13 +85,2 @@ if (err) { | ||
streamingClient.index({ | ||
type: 'tweet', | ||
id: '1', | ||
body: tweet | ||
}).on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
responseStream.on('data', function(res) { | ||
@@ -110,2 +101,15 @@ try { | ||
}) | ||
setTimeout(function() { | ||
streamingClient.index({ | ||
type: 'tweet', | ||
id: '1', | ||
body: tweet | ||
}).on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
}, 2000) | ||
}).on('error', function(err) { | ||
@@ -152,6 +156,7 @@ if (err) { | ||
}) | ||
responseStream.stop() | ||
var waitForEvent = setTimeout(function() { | ||
done(); | ||
}, 1000); | ||
}, 2000); | ||
first = false | ||
@@ -164,12 +169,14 @@ } else { | ||
streamingClient.index({ | ||
type: 'tweet', | ||
id: '1', | ||
body: tweet | ||
}).on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
setTimeout(function() { | ||
streamingClient.index({ | ||
type: 'tweet', | ||
id: '1', | ||
body: tweet | ||
}).on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
}, 2000) | ||
}).on('error', function(err) { | ||
@@ -176,0 +183,0 @@ if (err) { |
@@ -5,3 +5,3 @@ var assert = require('assert') | ||
streamSearchTests.streamMatchAll = function streamMatchAll(streamingClient, done) { | ||
streamSearchTests.streamMatchAllSingleType = function streamMatchAll(streamingClient, done) { | ||
var tweet = { | ||
@@ -81,2 +81,78 @@ "user": "olivere", | ||
streamSearchTests.streamMatchAllMultipleTypes = function streamMatchAll(streamingClient, done) { | ||
var tweet = { | ||
"user": "olivere", | ||
"message": "Welcome to Golang and Elasticsearch." | ||
} | ||
streamingClient.index({ | ||
type: 'tweet', | ||
id: '1', | ||
body: tweet | ||
}).on('data', function(res) { | ||
var first = true | ||
var responseStream = streamingClient.searchStream({ | ||
type: ['tweet', 'tweet2'], | ||
body: { | ||
query: { | ||
match_all: {} | ||
} | ||
} | ||
}) | ||
responseStream.on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
responseStream.on('data', function(res) { | ||
if (first) { | ||
streamingClient.index({ | ||
type: 'tweet', | ||
id: '1', | ||
body: tweet | ||
}).on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
first = false | ||
} else { | ||
try { | ||
assert.deepEqual(res, { | ||
_type: 'tweet', | ||
_id: '1', | ||
_source: tweet | ||
}, 'event not as expected') | ||
} catch (e) { | ||
responseStream.stop() | ||
return done(e) | ||
} | ||
responseStream.stop() | ||
done() | ||
} | ||
}) | ||
setTimeout(function() { | ||
streamingClient.index({ | ||
type: 'tweet', | ||
id: '1', | ||
body: tweet | ||
}).on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
}, 2000) | ||
}).on('error', function(err) { | ||
if (err) { | ||
done(err) | ||
return | ||
} | ||
}) | ||
} | ||
module.exports = streamSearchTests |
@@ -61,4 +61,8 @@ var appbase = require('../') | ||
it('should receive event when new document is inserted', function(done) { | ||
streamSearchTests.streamMatchAll(streamingClient, done) | ||
streamSearchTests.streamMatchAllSingleType(streamingClient, done) | ||
}) | ||
it('should receive event when new document is inserted while querying multiple types', function(done) { | ||
streamSearchTests.streamMatchAllMultipleTypes(streamingClient, done) | ||
}) | ||
}) | ||
@@ -65,0 +69,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
575234
54
13470