How to use getstream - 10 common examples

To help you get started, we’ve selected a few getstream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GetStream / react-native-activity-feed / example / scripts / test_notification.js View on Github external
console.error('STREAM_API_KEY should be set');
    return;
  }

  if (!appId) {
    console.error('STREAM_APP_ID should be set');
    return;
  }

  if (!apiSecret) {
    console.error('STREAM_SECRET should be set');
    return;
  }

  console.log(apiKey, apiSecret);
  let client: CloudClient = stream.connectCloud(apiKey, appId, {
    // urlOverride: {
    //   api: apiUrl,
    // },
    keepAlive: false,
  });

  function createUserSession(userId): UserSession {
    return client.createUserSession(
      stream.signing.JWTUserSessionToken(apiSecret, userId),
    );
  }

  let batman = createUserSession('batman');
  let content = 'test2';
  console.log(await batman.feed('notification').get({ limit: 1 }));
  await batman.feed('notification').addActivity({
github GetStream / react-activity-feed / src / errors.js View on Github external
export const getErrorMessage = (
  error: Error,
  type: FlowRequestTypes,
  detail: Object,
): string => {
  console.warn(error);
  if (!(error instanceof stream.errors.StreamApiError)) {
    return fallbackErrorMessage(error, type, detail);
  }
  const response = error.response;

  if (!response.statusCode || !response.body || !response.body.detail) {
    return fallbackErrorMessage(error, type, detail);
  }
  const statusCode = response.statusCode;
  const text = response.body.detail;

  /* eslint-disable no-magic-numbers */
  if (statusCode >= 400 && statusCode < 600) {
    return text;
  }
  /* eslint-enable no-magic-numbers */
github GetStream / Winds / api / src / shared / followPodcast.js View on Github external
// this is split out so that the auth controller can follow featured podcasts at user creation

import Follow from '../models/follow';
import config from '../config';
import stream from 'getstream';

const client = stream.connect(config.stream.apiKey, config.stream.apiSecret);

const followPodcast = (userID, podcastID) => {
	// couple things:
	// find follow relationship already in DB - if it exists, return it, don't send a 409
	// if not, create a new one, and:
	// timeline follows podcast
	// user_episode follows podcast
	let obj = {
		podcast: podcastID,
		user: userID,
	};
	return Follow.findOne(obj).then(existingFollow => {
		if (existingFollow) {
			// serialize podcast and user ids
			existingFollow.podcast = existingFollow.podcast._id;
			existingFollow.user = existingFollow.user._id;
github GetStream / react-native-activity-feed / example / scripts / test_notification.js View on Github external
function createUserSession(userId): UserSession {
    return client.createUserSession(
      stream.signing.JWTUserSessionToken(apiSecret, userId),
    );
  }
github GetStream / Winds / api / src / commands / resync-follows.js View on Github external
import '../loadenv';
import '../utils/db';
import program from 'commander';
import logger from '../utils/logger';
import Follow from '../models/follow';
import { FollowSchema } from '../models/follow';
import asyncTasks from '../asyncTasks';

import stream from 'getstream';
import config from '../config';

const streamClient = stream.connect(config.stream.apiKey, config.stream.apiSecret);

program.parse(process.argv);

async function main() {
	logger.info(`time to resync those follows, \\0/`);

	let followCount = await Follow.count({});
	let chunkSize = 500;

	for (let i = 0, j = followCount; i < j; i += chunkSize) {
		let follows = await Follow.find({})
			.skip(i)
			.limit(chunkSize)
			.lean();
		logger.info(`found ${follows.length} follows`);
		let feedRelations = [];
github GetStream / Winds / api / src / controllers / share.js View on Github external
import stream from 'getstream';

import Share from '../models/share';

import config from '../config';
import logger from '../utils/logger';

const client = stream.connect(
	config.stream.apiKey,
	config.stream.apiSecret,
);

exports.list = (req, res) => {
	const page = parseInt(req.query.page, 10) || 0;
	const perPage = parseInt(req.query.per_page, 10) || 10;

	Share.find({ flags: { $lte: 5 } })
		.skip(perPage * page)
		.limit(perPage)
		.then(shares => {
			res.json(shares);
		})
		.catch(err => {
			logger.error(err);
github GetStream / react-native-activity-feed / example / scripts / initData.js View on Github external
if (!apiKey) {
    console.error('STREAM_API_KEY should be set');
    return;
  }

  if (!appId) {
    console.error('STREAM_APP_ID should be set');
    return;
  }

  if (!apiSecret) {
    console.error('STREAM_SECRET should be set');
    return;
  }

  let client: CloudClient = stream.connectCloud(apiKey, appId);

  function createUserSession(userId): UserSession {
    return client.createUserSession(
      stream.signing.JWTUserSessionToken(apiSecret, userId),
    );
  }

  let batman = createUserSession('batman');
  let fluff = createUserSession('fluff');
  let league = createUserSession('justiceleague');
  let bowie = createUserSession('davidbowie');

  console.log('Add the following line to your .env file');
  console.log('STREAM_API_TOKEN=' + batman.token);

  await batman.user.getOrCreate({
github GetStream / react-native-activity-feed / src / errors.js View on Github external
export const getErrorMessage = (
  error: Error,
  type: FlowRequestTypes,
  detail: Object,
): string => {
  console.warn(error);
  if (!(error instanceof stream.errors.StreamApiError)) {
    return fallbackErrorMessage(error, type, detail);
  }
  const response = error.response;

  if (!response.statusCode || !response.body || !response.body.detail) {
    return fallbackErrorMessage(error, type, detail);
  }
  const statusCode = response.statusCode;
  const text = response.body.detail;

  if (statusCode >= 400 && statusCode < 500) {
    return text;
  } else if (statusCode >= 500 && statusCode < 600) {
    return text;
  }
github GetStream / mongodb-activity-feed / benchmark / utils.js View on Github external
export function getStreamClient() {
	let client = stream.connect(
		process.env.API_KEY,
		process.env.API_SECRET,
		process.env.APP_ID,
	)
	return client
}
github GetStream / react-native-activity-feed / src / Context / StreamApp.js View on Github external
constructor(props: StreamAppProps) {
    super(props);

    const client: StreamClient = stream.connect(
      this.props.apiKey,
      this.props.token,
      this.props.appId,
      this.props.options || {},
    );

    let analyticsClient;
    if (this.props.analyticsToken) {
      analyticsClient = new StreamAnalytics({
        apiKey: this.props.apiKey,
        token: this.props.analyticsToken,
      });
      analyticsClient.setUser(client.userId);
    }
    this.state = {
      client,

getstream

The official low-level GetStream.io client for Node.js and the browser.

BSD-3-Clause
Latest version published 1 year ago

Package Health Score

54 / 100
Full package analysis