@chatwithme/server
v1.0.6
Published
Chat With Me module for back-end
Readme
ChatWithMe Back Library
Installation
Firstly install the package with the command below in a nodejs project.
npm install @chatwithme/serverSetup your ChatWithMe token
You can grab it on chatwithme.fr. For more information: quickstart
import { CWMChat } from "@chatwithme/server";
CWMChat.appToken = process.env.CHAT_TOKENRetrieve token for your user
CWMChat.generateCWMUserToken({
userId: "<your user id>",
userName: "<your user name>"
}).then(token => {
console.log(token)
}).catch(() => {
// Handle error
})Create a POST route in your back end
Here a simple example with express.
import { CWMChat } from "@chatwithme/server";
app.post('/chat', (req, res) => {
const user = req.user;
if(user == undefined) {
res.status(400).json({ message: "You are not logged."})
}
CWMChat.generateCWMUserToken({
userId: user.id,
userName: name
}).then(token => {
res.json(token)
}).catch(() => {
// Handle error
})
})And it's done !
@chatwithme/client
After that you'll need to use another of our package in your front-end @chatwithme/client if it's not done yet.
