Skip to content

Instantly share code, notes, and snippets.

Last active October 11, 2021 17:54
What would you like to do?
Global Feed - Backend Server
const express = require('express')
let stream = require('getstream');
const app = express()
const port = 3000
const STREAM_API_KEY='qkswp9afyz49'
const STREAM_API_TOKEN='5fjsqcda7keu2v7s2tfmqyw2z3bedcm3d3f86jhmeu3fawhsace9apuda8chgm5k'
app.get('/', async (req, res) => {
// Connection to GetStream client
let client = await stream.connect(STREAM_API_KEY, STREAM_API_TOKEN);
// User private token creation
let userToken = await client.createUserToken('timeline');
// User creation
await client.user('tester').getOrCreate({
name: "Tester",
fullname: 'Tester',
// Addin user to a feed and to follow feed's activities
const timelineFeed = client.feed('timeline', 'timeline')
timelineFeed.follow('user', 'tester')
// Return private token and user id
res.send({userToken, userId: 'tester'})
app.listen(port, () => {
console.log(`Backend api listening at http://localhost:${port}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment