cent.js
Javascript library to communicate with Centrifugo HTTP API.
Installation
$ npm i cent.js
Usage
First see available API methods in documentation.
This library contains CentClient
class to send messages to Centrifugo from your node-powered backend:
const {CentClient} = require('cent.js');
const client = new CentClient({
url: 'http://localhost:8000/api',
apiKey: 'XXX'
});
const publishRes = await client.publish({
channel: 'public:chat',
data: {input: "test"}
}).catch(err => handleError());
await client.unsubscribe({user: 'user_id', channel: 'channel'});
await client.disconnect({user: 'user_id'})
await client.getHistory({channel: 'channel'})
await client.getPresence({channel: 'channel'})
await client.getChannels()
await client.getInfo()
await client.removeHistory({channel: 'channel'})
Stay in touch
License
MIT © Alexey Filippov