GithubHelp home page GithubHelp logo

getstream / stream-node-orm Goto Github PK

View Code? Open in Web Editor NEW
130.0 42.0 20.0 619 KB

NodeJS Client - Build Activity Feeds & Streams with GetStream.io

Home Page: https://getstream.io/

License: BSD 3-Clause "New" or "Revised" License

JavaScript 99.51% Shell 0.49%
nodejs javascript waterline sailsjs stream-node-orm activity-feed timeline feed getstream-io notification-feed news-feed

stream-node-orm's People

Contributors

astrotars avatar concentriccircles avatar dependabot[bot] avatar dwightgunning avatar ferhatelmas avatar kenhoff avatar mahboubii avatar matthisk avatar navyxie avatar ruggi avatar tbarbugli avatar tschellenbach avatar zclancy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stream-node-orm's Issues

Custom config file directory is not working

The code below is the one that allows someone to specifiy a different directory for the getstream.js config file"

if (typeof process != 'undefined' && process.env.STREAM_NODE_CONFIG_DIR) {
		config_file = process.env.STREAM_NODE_CONFIG_DIR + '/getstream.js';
	} else {
		config_file = process.cwd() + '/getstream.js';
	}

The main problem is that, in case we specify a value for STREAM_NODE_CONFIG_DIR this will always be some path relative to the project. Therefore, we must append the process.cwd() to the url.

Moreover, I'm working now with Node v14 and, because of compatibility things, I need to specifiy getstream.js with the .cjs extension. But this is not possible with the current setup because stream-node-orm is forcing us to use a file named getstream.js.

My proposal is just to use a STREAM_NODE_CONFIG_PATH variable that would be path to a file and not a directory path.

Cannot find module 'mongoose'

I am trying to run this according this docs:
https://getstream.io/docs/js/#enrichment

I am getting this error:

Error: Cannot find module 'mongoose'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/alexprice/code/private/opt-in/node_modules/getstream-node/src/backends/mongoose.js:4:16)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/alexprice/code/private/opt-in/node_modules/getstream-node/src/index.js:5:16)

require('getstream-node') throws exception

I have a one-line test.js file:

require('getstream-node');

When running it with node test.js, I get this exception: Error: secretOrPrivateKey must have a value, requiring the getstream.js file and mongoose before doesn't help.

Support Async Configuration for Managed Secrets

When using hosted managed secrets (ie. Google Secret Manager), it is impossible to pass async configuration into the automatically instantiated version of FeedManager. This can be achieved with the feedManagerFactory, however module.exports.FeedManager is still created, and will fail without getstream.js configuration present.

Initiate FeedManager with a configuration object

To make the module more flexible, would it be an idea to instantiate the Feedmanager with an object? Instead of a file in the application's root?
In my case I have a settings file ./config/settings.js which stores all application environment variables (including the stream keys).
And I have a ./config/getstream.js with:

var settings = require('./settings');
module.exports = {
  apiKey: settings.getStream.key,
  apiSecret: settings.getStream.secret,
  apiAppId: settings.getStream.appId,
  apiLocation: '',
  userFeed: 'user',
  notificationFeed: 'notification',
  newsFeeds: {
    flat: 'timeline',
    aggregated: 'timeline_aggregated'
  }
};

I then initiate the feedmanager with

var streamConfig = require('../../config/getStream');
var FeedManager = stream_node.FeedManager(streamConfig);

mocha test/backends fails

removed it from the test flow for now. let's review what those tests were supposed to do and if we need them.

Node 10?

Hi! Trying to test getstream. However, I can't install it due to:

The engine "node" is incompatible with this module. Expected version ">=4.8 <=9".

Actor prop author not found on model instance

here's my code
`export const ArticleSchema = new Schema(
{
slug: {type: String, lowercase: true, unique: true},
title: {
type: String,
required: true,
},
body: {
type: String,
required: true,
},
description: {
type: String,
},
likes: {type: Number, default: 0},
tagList: [{ type: String}],
author:{ type: mongoose.Schema.Types.ObjectId, ref: 'User',
autopopulate:true
},
comments: [{
body:{ type: String, maxlength: 280},
commenter: { type: mongoose.Schema.Types.ObjectId, ref: "User", autopopulate:true},
commentedAt:Date,
replies:[{
reply:{ type: String, default: "", maxlength: 280},
replyAuthor:{type:mongoose.Schema.Types.ObjectId, ref:'User'}
}]
}],
}
);
ArticleSchema.plugin(stream.mongoose.activity);

ArticleSchema.methods.activityActorProp = function() {
return 'author';
}`

TypeScript / TypeORM Support

Hi guys, I see some issue stalled talking about mongoose, but I want to actually use stream with my TypeORM project, using TypeScript.

Should this be doable? Is there any shot at stream/typescript/typeorm I'm not aware of?

Errors unhandled in ORM

Another dev I'm working with ended up hunting for half-an-hour looking for a reason why an activity wasn't triggering as expected, turns out there was a typo in the field.

However, definitely something avoidable if errors were accessible from the mongoose hooks. Right now they end up unhandled:

doc.populate(paths, function(err, docP) {
if (docP.wasNew) {
stream.FeedManager.activityCreated(docP);
}
});

TypeError: instance.createActivity is not a function

Hey,

I'm getting the following error. I have no clue why.
Any input would be greatly appreciated.

(node:283) [MONGODB DRIVER] Warning: Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
events.js:377
      throw er; // Unhandled 'error' event
      ^
TypeError: instance.createActivity is not a function
    at FeedManager.activityCreated (/app/node_modules/getstream-node/src/FeedManager.js:78:28)
    at /app/node_modules/getstream-node/src/backends/mongoose.js:106:24
    at /app/node_modules/mongoose/lib/model.js:5074:18
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
Emitted 'error' event on Function instance at:
    at /app/node_modules/mongoose/lib/model.js:5076:15
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

Follow are my model and app.js files

/* model.js */
import mongoose, { Schema } from 'mongoose'
import stream from 'getstream-node'

var FeedManager = stream.FeedManager;

const favouriteSchema = new Schema({
  user: {
    type: Schema.ObjectId,
    ref: 'User',
    required: true
  },
  product: {
    type: Schema.ObjectId,
    ref: 'Product',
    required: true
  }
}, {
  timestamps: true,
  toJSON: {
    virtuals: true,
    transform: (obj, ret) => { delete ret._id }
  }
})

favouriteSchema.plugin(stream.mongoose.activity)

const model = mongoose.model('Favourite', favouriteSchema)

export const schema = model.schema
export default model
/* app.js */
import http from 'http'
import { env, mongo, port, ip, apiRoot } from './config'
import mongoose from './services/mongoose'
import express from './services/express'
import api from './api'
import stream from 'getstream-node'

const app = express(apiRoot, api)
const server = http.createServer(app)

if (mongo.uri) {
  mongoose.connect(mongo.uri)
}
mongoose.Promise = Promise



setImmediate(() => {
  server.listen(port, ip, () => {
    console.log('Express server listening on http://%s:%d, in %s mode', ip, port, env)
  })
});

stream.mongoose.setupMongoose(mongoose);

export default app

Package still use getstream 5.0.0

Hello,
It would be nice to upgrade the dependency for the last version of getstream.
For example: I am not able to use client.feed('user', 'me').followStats() directly with the low level APIs access by using: streamNode.FeedManager.client.

newsFeeds[slug].follow is not a function

I've been following the Node.js example and I keep getting
newsFeeds[slug].follow is not a function
and
newsFeeds[slug].unfollow is not a function,
while providing all the correct data.

I looked into the module's FeedManager.js file, as the error was being generated there and swapped the enhanced loop
for (var slug in newsFeeds) {
on lines 52 and 64 to the regular
for(var slug=0; slug< newsFeeds.length; slug++){
and it worked perfectly.

Do you know why might this be happening and is there a way to fix this without making a custom module?

API keys not accessible from getstream.js file

I've copied the getstream.js file into the root directory and filled in all the API keys info, but seems like the module cannot access this data.

I've also tried creating a getstream.json as instructed here and adding the path to STREAM_NODE_CONFIG_DIR in the .env, but that doesn't work either.

Only way to make the module accept the keys was to enter them directly in config.default.js.

Is my configuration somehow incorrect? Please let me know what can be done to fix this.

stream is not defined error

Hi,

I am getting the following error

ReferenceError: stream is not defined at F:\mightybolder\boldersocial\node_modules\getstream-node\src\backends\mongoose.js:100:9 at F:\mightybolder\boldersocial\node_modules\mongoose\lib\model.js:3369:16 at next (F:\mightybolder\boldersocial\node_modules\mongoose\lib\model.js:2621:5) at populate (F:\mightybolder\boldersocial\node_modules\mongoose\lib\model.js:2709:12) at _populate (F:\mightybolder\boldersocial\node_modules\mongoose\lib\model.js:2611:5) at Function.Model.populate (F:\mightybolder\boldersocial\node_modules\mongoose\lib\model.js:2571:5) at model.populate (F:\mightybolder\boldersocial\node_modules\mongoose\lib\document.js:2449:22) at model.<anonymous> (F:\mightybolder\boldersocial\node_modules\getstream-node\src\backends\mongoose.js:98:9) at EventEmitter.<anonymous> (F:\mightybolder\boldersocial\node_modules\mongoose\lib\schema.js:1084:17) at emitTwo (events.js:106:13) at EventEmitter.emit (events.js:191:7)

In recent commit it seems to be that stream import is deleted from src\backends\mongoose.js.
Please help, thanks in advance

Ability to restrict attributes when enriching activities

Problem: Not all attributes are needed when enriching activities. In some cases, it's desirable to hide values (e.g. e-mail address, hashed passwords, other secrets). Calling StreamBackend.enrichActivities appears to return all attributes for each document found.

It would be great to be able to define a projection, or some other spec to define which attributes will be included or excluded on a per-model/schema basis.

It seems that this is a common use-case. Suggestions/ideas on solutions to this problem would be much appreciated.

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.