Skip to content

Instantly share code, notes, and snippets.

@jetaggart
Created June 29, 2020 18:39
Show Gist options
  • Select an option

  • Save jetaggart/e3a6997bdab1d3afc4da222da3a9089d to your computer and use it in GitHub Desktop.

Select an option

Save jetaggart/e3a6997bdab1d3afc4da222da3a9089d to your computer and use it in GitHub Desktop.
// backend/src/controllers/v1/stream-feed-credentials/stream-feed-credentials.action.js:1
import dotenv from 'dotenv';
import stream from "getstream";
dotenv.config();
exports.streamFeedCredentials = async (req, res) => {
try {
const apiKey = process.env.STREAM_API_KEY;
const apiSecret = process.env.STREAM_API_SECRET;
const appId = process.env.STREAM_APP_ID;
const client = stream.connect(apiKey, apiSecret, appId);
await client.user(req.user).getOrCreate({ name: req.user });
const token = client.createUserToken(req.user);
res.status(200).json({ token, apiKey, appId });
} catch (error) {
console.log(error);
res.status(500).json({ error: error.message });
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment