getstream / stream-js Goto Github PK
View Code? Open in Web Editor NEWJS / Browser Client - Build Activity Feeds & Streams with GetStream.io
Home Page: https://getstream.io
License: BSD 3-Clause "New" or "Revised" License
JS / Browser Client - Build Activity Feeds & Streams with GetStream.io
Home Page: https://getstream.io
License: BSD 3-Clause "New" or "Revised" License
getstream.js for parse cloud code has error:
Result: ReferenceError: setTimeout is not defined
at nextTick (getstream.js:18709:9)
at onwrite (getstream.js:20191:7)
at WritableState.onwrite (getstream.js:20025:5)
at afterTransform (getstream.js:19806:5)
at TransformState.afterTransform (getstream.js:19781:12)
at Hash._transform (getstream.js:61:3)
at Hash.Transform._read (getstream.js:19886:10)
at Hash.Transform._write (getstream.js:19874:12)
at doWrite (getstream.js:20152:10)
at writeOrBuffer (getstream.js:20142:5)
I downloaded from:
https://raw.githubusercontent.com/GetStream/stream-js/parse/dist/js/getstream.js
We clearly need to split our tests in these groups:
we should only run unit tests for regular builds. integration tests and browser tests should be run as part of the release cycle (eg. npm release_test, npm browser_test, npm integration_test).
client.feed('notification', id).addActivity({
"actor": id2,
"actorName": "abc",
"verb": "follow"
});
body:{
"code": 5,
"detail": "Please use actorname instead of actorName for your field name",
"duration": "10ms",
"exception": "CustomFieldException",
"status_code": 400
}
err = null
Hello, could you help me with this problem:
emberjs uses this:
http://yui.github.io/yuidoc/
I was exploring "Targetting & To Supports" of your wonderful platform.
Every time, I insert new activity with "to" field, I get following error messge:
"detail": "Errors for fields 'to'",
"duration": "7ms",
"exception": "InputException",
"exception_fields": {
"to": [
{
"0": [
"Invalid value."
]
}
]
},
"status_code": 400
Without "to", it works fine.
This is how I am inserting new activity to user feed:
var streamActivityObj={
.....
verb: obj.verb,
object: {
content: obj.content,
object_type: obj.object_type
},
target: obj.target,
to: ["flat:5648e69f40d7a92b71fc9690"],
foreign_id: some_id,
....
}
//Insert to ufeeds....
var currentActorFeed = con.uFeeds[kinId];
currentActorFeed.addActivity(streamActivityObj, function (errorAddingActivity, responseAddingActivity, bodyAddingActivity) {
if (errorAddingActivity) {
return cb(errorAddingActivity, null);
I tried debugging, and it seems that the flatfeed is valid as well.
Dump of flatfeed for userId= 5648e69f40d7a92b71fc9690
node: true }, slug: 'flat', userId: '5648e69f40d7a92b71fc9690', id: 'flat:5648e69f40d7a92b71fc9690', token: 'mxcxmcxmnmcxnxcmnxcncncxmnxcmcnx'fake', feedUrl: 'flat/5648e69f40d7a92b71fc9690', feedTogether: 'flat5648e69f40d7a92b71fc9690',
..........................................
Could you please help me in this regard?
Thanks.
The request library issues an options request before making the API call.
This leads to 2 requests instead of one
Here's an example of how I get the request for the feed to work, it should come back in the argument of the callback result argument, here's how i have to get the result, this works differently than subscribing to a feed:
UserFeedCollection.prototype.subscribeToFeed = function() {
return this.me.subscribe((function(_this) {
return function(data) {
return _this.addOneAtIndex(data, 0);
};
})(this));
};
UserFeedCollection.prototype.fetch = function(lastSeenId) {
var xmHttpR;
this.lastSeenId = lastSeenId != null ? lastSeenId : 0;
if (this.lastSeenId !== 0) {
this.me.get({
limit: this.pageLimit,
mark_seen: true
});
} else {
this.me.get({
limit: this.pageLimit,
id_lt: this.lastSeenId
});
}
xmHttpR = this.me.get({
limit: 10,
mark_seen: true
});
xmHttpR.onload = (function(_this) {
return function(data) {
var item, list, _i, _len, _ref, _ref1, _results;
list = data != null ? (_ref = data.target) != null ? (_ref1 = _ref.body) != null ? _ref1.results : void 0 : void 0 : void 0;
if (!list) {
return _this.trigger('sync');
}
_results = [];
for (_i = 0, _len = list.length; _i < _len; _i++) {
item = list[_i];
console.log('item', item);
_results.push(_this.addOne(item));
}
return _results;
};
})(this);
return this.trigger('sync');
};
that's around 50k, way too much. blame goes to faye-browser and buffer (80k and 45k before minification)
filter=['feed:1', 'feed:2'] should be converted as filter='feed:1,feed:2'
Right now if you install stream-js via npm and require it in a frontend project the build will fail. This is because package.json sets the property "main" to the src entry "./src/getstream.js". We should investigate using the "browser" or "browserify" package.json property to tell build tool chains to include a distributable specifically build for the frontend. Webpack config needs to include a separate target.
Hello,
I am using Getstream.io with parse cloud code. I am using this https://raw.githubusercontent.com/GetStream/stream-js/parse/dist/js/getstream.js code.
I need to generate read only token but seems like that method does not exists in this code. How can I generate it?
Currently auth and connection are tied together. This means you cant subscribe to multiple feeds without creating multiple connections.
We should research if this can be improved and if doing so improves performance
Often you'll want a global behaviour for loading and error handling. Currently this is not supported.
We could do something like
client.on('pre_request', callback);
client.on('response', callback);
@tbarbugli what do you think?
eg. currently we have a mix of 2 and 4 spaces tabs. let's make sure code follows the same style (https://github.com/airbnb/javascript#the-javascript-style-guide-guide looks reasonable and comes with some nice linter configs)
Regular responses get passed as errors:
https://github.com/GetStream/stream-js/blob/parse/src/lib/parse_request.js
Make it easy to use Stream with promises, while maintaining backward compatibility.
JWT support expiration via iat field. Token should not expire by default (no iat field) and make it configurable (client init option).
relevant code:
https://github.com/GetStream/stream-js/blob/master/src/lib/signing.js#L89
https://github.com/auth0/node-jsonwebtoken/blob/master/index.js#L57
useful link for debugging: jwt.io
on the js client
user1.following({limit: '10', offset: '0', feeds: ['user:42', 'user:43']})
on python client (same for php and ruby)
user_feed_1.following(offset=0, limit=2, filter=['user:42', 'user:43'])
Coverage has dropped to 76%. Time to improve that :)
Code style: addActivity should call addActivities
current distributable is using ES6. we should transpile to ES5 as part of the build
(see other clients for reference)
send target_token as part of post body containing the signature token of the target feed id (eg. secret:42)
the test account has a private feed configured (slug secret)
both feed reads and writes are not supported. This is related to (missing) CORS support in IE9. We should at least add read support via JSONP
use api.getstream.com and faye.getstream.com
USER_AGENT should be "stream-javascript-client-" + version
question: can we detect if the client is used server-side or in the browser? (eg. nodejs VS browser)
Accidentally typed the name of my feed slug in incorrectly and did not get the behavior I expected...
var stream = require("getstream");
var client = stream.connect("REDACTED", "REDACTED");
var aggregated1 = client.feed("agggggregated", "1");
aggregated1.follow("user", "1", function(err, resp, body) {
console.log("Err: ", err);
console.log("Body: ", body);
});
This gives me the following output:
Err: null
Body: { code: 6,
detail: 'The following feeds are not configured: \'agggggregated\'',
duration: '13ms',
exception: 'FeedConfigException',
status_code: 400 }
With some different slug names, different errors can result (I tried "does-not-exist" for testing and it gave a 404 instead of 400)
I would have expected the API to return an error (via the err arguments in the callback).
I have not assessed deeper yet but I suspect other APIs have similar issues.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.