GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SocketSomeone/cent.js: 👀 Javascript library to communicate with Centrifugo HTTP API

BranchesTags
Open more actions menu

Latest commit

 

History

1,297 Commits
1,297 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.husky
.husky
 
 
src
src
 
 
test
test
 
 
.commitlintrc.json
.commitlintrc.json
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
.oxlintrc.json
.oxlintrc.json
 
 
.prettierrc
.prettierrc
 
 
.release-it.json
.release-it.json
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.build.json
tsconfig.build.json
 
 
tsconfig.json
tsconfig.json
 
 
vitest.config.mts
vitest.config.mts
 
 

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:

import { CentClient } from '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'})

cent.js is a native ESM package. The ESM-only package boundary is a breaking change for older Node.js releases and CommonJS loaders. Use Node.js 20.19.x or Node.js 22.13+.

Modern CommonJS applications on those Node.js versions can synchronously load the same ESM package:

const { CentClient } = require('cent.js');

Stay in touch

  • Author - Alexey Filippov
  • Twitter - @SocketSomeone

License

MIT © Alexey Filippov

About

👀 Javascript library to communicate with Centrifugo HTTP API

npmjs.com/package/cent.js

Topics

centrifugalcentrifugecentrifugonodejswebsocketwebsocketsws

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity

Stars

21 stars

Watchers

1 watching

Forks

7 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.