Created
May 12, 2020 14:48
-
-
Save dongido001/b3e5b9258d9817d0d15449809dbc1e3c to your computer and use it in GitHub Desktop.
This file contains 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
// [...] | |
// Stream Chat server SDK | |
const StreamChat = require('stream-chat').StreamChat; | |
const serverClient = new StreamChat( | |
'<STREAM_API_KEY>', | |
'<STREAM_API_SECRET>' | |
); | |
app.get('/token', (req, res) => { | |
const { username } = req.query | |
if (username) { | |
const token = serverClient.createToken(username) | |
res.status(200).json({ token, status: "sucess" }) | |
} else { | |
res.status(401).json({ message: "invalid request", status: "error" }) | |
} | |
}); | |
// [...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment