Created
June 29, 2020 18:39
-
-
Save jetaggart/e3a6997bdab1d3afc4da222da3a9089d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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