Skip to content

Build newsfeeds and activity feeds on node.js using getstream.io

License

Notifications You must be signed in to change notification settings

tbarbugli/stream-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stream Node

Build Status

Install

. Install getstream-node via npm install getstream-node for your application
. Copy getstream.js config file from node_modules/getstream-node into the root directory of your application
. Edit getstream.js and set your API keys (https://getstream.io/dashboard)
. Add require('getstream-node'); early on in your application code

If you wish to keep the configuration for the module separate from your application, the module will look for getstream.json in the directory referenced by the environment variable STREAM_NODE_CONFIG_DIR if it's set.

Mongoose integration

Register the models' schemas that you want to store in feeds:

var stream = require('getstream-node');

var tweetSchema = Schema({
  text    : String,
  actor   : { type: Schema.Types.ObjectId, ref: 'User' },
  bg      : String,
  link    : { type: Schema.Types.ObjectId, ref: 'Link' }
});

stream.mongoose.activitySchema(tweetSchema);

Make sure you register your mongoose connection or things won't work!

stream_node.mongoose.setupMongoose(mongoose);

Store extra information in feeds:

tweetSchema.methods.activityExtraData = function() {
  return {'bg': this.bg, 'link': this.link};
}

Automatically populate paths:

tweetSchema.statics.pathsToPopulate = function() {
  return ['actor', 'link'];
};

Use custom attribute for the actor field:

tweetSchema.methods.activityActorProp = function() {
  return 'actor';
}

About

Build newsfeeds and activity feeds on node.js using getstream.io

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published