npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jambonz/realtimedb-helpers

v0.8.11

Published

utility functions for querying jambonz redis database

Downloads

875

Readme

jambonz-realtimedb-helpers CI

A set of helper functions to access data in the jambonz in-memory database (currently implemented using redis).

This module exposes a function that should be called with redis configuration options and, optionally, a pino logger function. It then returns an object containing various useful functions for accessing and updating the database.

If standalone redis is used:

const opts = {
  "host": "localhost",
  "port": 3279
};
const logger = require('pino')();
const {updateCallStatus} = require('jambonz-realtimedb-helpers')(opts, logger);

If redis with authentication is used:

const opts = {
  "host": "localhost",
  "port": 3279,
  "username": "daveh",
  "password": "password"
};
const logger = require('pino')();
const {updateCallStatus} = require('jambonz-realtimedb-helpers')(opts, logger);

If redis Sentinel is used:

const opts = {
  sentinels: [
    { host: '54.53.52.51', port: 6379 },
    { host: '54.53.52.52', port: 6379 },
    { host: '54.53.52.53', port: 6379 },
  ],
  name: 'masterNodeName',
};
const logger = require('pino')();
const {updateCallStatus} = require('jambonz-realtimedb-helpers')(opts, logger);

Functions

  • updateCallStatus - adds or updates the call status for a given call identified by call Sid.
  • retrieveCallInfo - retrieves the call data for a call.
  • listCallInfo - retrieves all the calls for a given account
  • deleteCall - removes call data for a call.
  • purgeCalls - removes call data for all calls that completed some time ago.
  • synthAudio - retrieves generated tts audio from cache, or generates it

updateCallStatus

updateCallStatus(callInfo, serviceUrl)

Adds or updates the information about a call. The callInfo object must contain (at least) the following properties:

| property | description | | ------------- |-------------| | callSid | the Call Sid for this call| | callId | the SIP Call-ID | | sipStatus | the most recent sip status - a value of 100 means this is a new call that should be added| | callStatus | one of 'trying', 'ringing', 'early-media', 'in-progress', 'completed', 'failed', 'busy', 'no-answer', or 'queued'|

Additionally, the serviceUrl parameter is required if the sipStatus is 100 (i.e. a new call). It must contain the service endpoint of the specific feature-server instance that is controlling this call.

When a call reaches a final state ('completed', 'failed', 'busy', or 'no-answer') the associated call data will be purged one hours later. This database is intended only to be used for live call information.

retrieveCallInfo

retrieveCallInfo(accountSid, callSid)

Retrieves the call information associated with a given call sid, if available.

const callInfo = await retrieveCallInfo(accountSid, callSid);
if (!callInfo) {
  logger.info(`call for ${callSid} not found);
}

listCallInfo

listCallInfo(accountSid)

Retrieves all of the active (or recently-active) calls for an Account.

const calls = await listCallInfo(accountSid);

deleteCall

deleteCall(accountSid, callSid)

Deletes a Call.

const result = await deleteCall(accountSid, callSid);

purgeCalls

purgeCalls()

Purges call data for calls that ended some time ago.

const countDeleted = await purgeCalls();

synthAudio

synthAudio({vendor, language, voice, text})

Generates audio for text, retrieving previously generated audio from cache if available. Audio is cached for 24 hours.

const path = await synthAudio({
  vendor: 'aws', 
  language: 'en-US', 
  voice: 'Amy', 
  text: 'This is a test'
});