5.0.0 • Published 1 month ago

cent.js v5.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

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.
const client = new CentClient({
    url: 'http://localhost:8000/api',
    apiKey: 'XXX'
});

// Publish data into channel
const publishRes = await client.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 methods
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

5.0.0

1 month ago

3.0.2

10 months ago

4.0.0

6 months ago

3.0.1

1 year ago

3.0.0

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.2

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.1

1 year ago

2.0.7

2 years ago

2.0.6

2 years ago

2.1.0

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago