Skip to content

Repository files navigation

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');// Initialize client instance.constclient=newCentClient({url: 'http://localhost:8000/api',apiKey: 'XXX'});// Publish data into channelconstpublishRes=awaitclient.publish({channel: 'public:chat',data: {input: "test"}}).catch(err=>handleError());// We throw error in case of unsuccessful// response from Centrifugo or some other // internal errors.// Other available methodsawaitclient.unsubscribe({user: 'user_id',channel: 'channel'});awaitclient.disconnect({user: 'user_id'})awaitclient.getHistory({channel: 'channel'})awaitclient.getPresence({channel: 'channel'})awaitclient.getChannels()awaitclient.getInfo()awaitclient.removeHistory({channel: 'channel'})

Stay in touch

License

MIT © Alexey Filippov

About

👀 Javascript library to communicate with Centrifugo HTTP API

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

21 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages