Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including freepbx with all npm packages installed. Try it out:

var freepbx = require("freepbx")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

freepbx v2.1.3

The FreePBX connector for NodeJS modules. Allows NodeJS modules to access common functions in FreePBX systems. Also simulates the FreePBX boostrap

FreePBX Node JS Module

This module is used to connect a Node Process to the FreePBX ecosystem. It basic mysql and asterisk manager connections that you can interact with as well

npm install freepbx --save

Usage

You can utilize FreePBX like so:

var FreePBX = require("freepbx");

FreePBX.connect().then(function (pbx) {
    //FreePBX is now ready
    //pbx.ami == https://github.com/pipobscure/NodeJS-AsteriskManager
    //pbx.db == https://github.com/mysqljs/mysql
    //pbx.kvstore == FreePBX kvstore
    //pbx.config == FreePBX Config

    //Note these two are promised based libraries!!
    //freepbx.config == see example below:

    pbx.config.get("VALUE FROM ADVANCED SETTINGS")
    .then(function(val) {
        console.log(val);
    }).catch(function(err) {
    });;

    //freepbx.kvstore == see examples below:

    console.log("PBX is ready");
    pbx.kvstore.setConfig('Dashboard','foo',"hello world")
    .then(function(res) {
        return pbx.kvstore.getConfig('Dashboard','foo')
    })
    .then(function(val) {
        console.log(val)
    }).catch(function(err) {
        console.log(err);
    });
});

Building

All development should be done in the src/ directory. When finished editing/testing then execute the grunt file as so:

grunt

This will update the files in dist/ for distribution to npmjs.org

The repository is at: https://git.freepbx.org/projects/FL/repos/freepbx-nodejs/browse

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free