Skip to content

Instantly share code, notes, and snippets.

@dongido001
Created May 12, 2020 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dongido001/b3e5b9258d9817d0d15449809dbc1e3c to your computer and use it in GitHub Desktop.
Save dongido001/b3e5b9258d9817d0d15449809dbc1e3c to your computer and use it in GitHub Desktop.
// [...]
// 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