getstream / stream-node-orm Goto Github PK
View Code? Open in Web Editor NEWNodeJS Client - Build Activity Feeds & Streams with GetStream.io
Home Page: https://getstream.io/
License: BSD 3-Clause "New" or "Revised" License
NodeJS Client - Build Activity Feeds & Streams with GetStream.io
Home Page: https://getstream.io/
License: BSD 3-Clause "New" or "Revised" License
Since there is room for multiple backends, wouldn't it be nice to make this a configuration option?
So in getstream.js you would have:
exports.config = { backend: 'waterline', ... etc ... }
and then load the backend conditionally in https://github.com/GetStream/stream-node-orm/blob/master/src/index.js
removed it from the test flow for now. let's review what those tests were supposed to do and if we need them.
gestream-js had a braking changes since version 5.0.0 https://github.com/GetStream/stream-js/blob/master/CHANGELOG.md#500---2020-07-06
Now when require('getstream-node') it is throwing an exception for missing function connect: "stream.connect is not a function".
Thanks
Is it now recommended for new applications to use the newer stream-js package?
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);
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';
}`
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.
replace >= with ~
let's find out and add that to the docs or in package.json if there is a nice way to do it
http://getstream.io/docs/#frameworks
doesn't link to:
https://github.com/getstream/stream-node
our JS client also doesn't link to it.
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?
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
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)
how do we know if it is supported?
One of our customers uses it
It seems that this module now loads alle backends. e.g. It always loads Mongoose even if you are not using this in your own application.
Shouldn't only the backend that is being used in the application be used https://github.com/GetStream/stream-node-orm/blob/master/src/index.js#L22
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.
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.
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.
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
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:
stream-node-orm/src/backends/mongoose.js
Lines 104 to 108 in 14ca95f
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".
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?
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.
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!
I'm working on a project that's built on Koa2 and RethinkDB. Could I integrate stream-node-orm in?
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.