Skip to content

Instantly share code, notes, and snippets.

@KingIdee
Last active April 15, 2020 10:22
Show Gist options
  • Save KingIdee/415e9fff09e8b67737883ca704f8e994 to your computer and use it in GitHub Desktop.
Save KingIdee/415e9fff09e8b67737883ca704f8e994 to your computer and use it in GitHub Desktop.
// index.js
const express = require('express');
const StreamChat = require('stream-chat').StreamChat;
const bodyParser = require('body-parser');
const app = express();
const client = new StreamChat('API_KEY', 'API_SECRET');
app.use(bodyParser.json());
app.post('/token', (req, res, next) => {
const userToken = client.createToken(req.body.userId);
res.json({success: 200, token: userToken});
});
app.listen(4000, _ => console.log('App listening on port 4000!'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment