# modesl

> FreeSWITCH ESL Node.js Implementation

Latest version **1.2.1** (published 2019-07-07) · 0 weekly downloads

## Install

```sh
npm install modesl
pnpm add modesl
yarn add modesl
bun add modesl
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2019-07-07 |
| First published | 2012-10-01 |
| Weekly downloads | 0 |
| TypeScript types | separate (@types/modesl) |
| Module format | CommonJS |
| Node | >=1.x |
| Dependencies | 3 |
| Unpacked size | 952.2 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 175 |
| Author | Chad Engler |
| Maintainers | englercj |
| Keywords | freeswitch, api, wrapper, esl, event, socket, library |

## Links

- npm: https://www.npmjs.com/package/modesl
- Repository: https://github.com/englercj/node-esl
- Issues: https://github.com/englercj/node-esl/issues
- npm.io page: https://npm.io/package/modesl

## Dependencies (3)

- [uuid](https://npm.io/package/uuid.md) ^3.1.0
- [xml2js](https://npm.io/package/xml2js.md) ^0.4.19
- [eventemitter2](https://npm.io/package/eventemitter2.md) ^4.1

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2019-07-07
- 1.2.0 — 2017-09-14
- 1.1.9 — 2017-03-09
- 1.1.8 — 2016-01-05
- 1.1.7 — 2016-01-04
- 1.1.6 — 2015-10-30
- 1.1.5 — 2015-07-19
- 1.1.4 — 2015-07-07
- 1.1.3 — 2015-03-23
- 1.1.2 — 2014-07-15
- 1.1.1 — 2014-04-17
- 1.1.0 — 2014-04-15
- 1.0.1 — 2014-04-15
- 1.0.0 — 2014-04-15
- 0.0.13 — 2014-03-28
- … 12 more at https://npm.io/package/modesl/versions

## README

## FreeSWITCH ESL Bindings for Node.js [![Build Status](https://travis-ci.org/englercj/node-esl.svg?branch=master)](https://travis-ci.org/englercj/node-esl)

A Library for handling low-level FreeSWITCH ESLconnections, and associated ESLevents.

[Documentation](https://github.com/englercj/node-esl/wiki) - [Event Socket Library Spec](http://wiki.freeswitch.org/wiki/Esl)

### Purpose

Though there is already a Node.js "library" for this [on github](https://github.com/shimaore/esl),
it does not actually implement the [Event Socket Library](http://wiki.freeswitch.org/wiki/Event_Socket_Library)
interface, and instead has it's own thing. This library was written to implement the full Event
Socket Library interface, and provide a meaningful semantic when dealing with FreeSWITCH in Node.js.

This library supports both "Inbound" (connection going _into_ FreeSWITCH) and "Outbound" (connections
coming _out_ of FreeSWITCH). Also included is a helper `esl.Server` object that manages multiple
`esl.Connection` objects; making it trivial to have multiple "Outbound" connections from FreeSWITCH.

### Installation

The easiest way to install is via npm:

```shell
npm install modesl
```

As in "Mod ESL".

### Usage

The most basic usage example is to open a connection, and send a status command:

```javascript
var esl = require('modesl'),
conn = new esl.Connection('127.0.0.1', 8021, 'ClueCon', function() {
    conn.api('status', function(res) {
        //res is an esl.Event instance
        console.log(res.getBody());
    });
});
```

Something to be aware of is that _all_ functions that interact with FreeSWITCH are asynchronous on the Library side.
However, there are many functions (`api`, `execute`, etc) that are synchronous on the FreeSWITCH side. Because of this
the event you will get back in your callback on, for example, `api` and the same command on `bgapi` will be different.

The `api` command's callback will be executed immediately when the `command/reply` message is received, with all the
returned data. However, that same command using `bgapi` will _not_ call the callback when the `command/reply` message
is received, this is because FreeSWITCH returns the `command/reply` message immediately for background commands __before
the command is run__. The Library will automatically track the command, and call the callback on the `BACKGROUND_JOB`
message that denotes a completed Background Job.

The body for the same command issued with `api` and `bgapi` should be the same; even when the headers, event type, and
time it takes for the callback to execute are different. The Library attempts to smooth these differences out by providing
a common interface, even though behind the scenes things are quite different.

### Tests

To run the tests included with the module simply run the following in the root of the `modesl` folder:

```shell
npm test
```

### TODO

 - Add tests for
  * `esl.Connection`
 - Add more examples for
  * IVR App
  * Faxing App
 - Add more abstraction/sugar functions
 - Better error messages on `error` event

### License

This module is distributed under the [Mozilla Public License 2.0](http://www.mozilla.org/MPL/2.0/).

---
_Source: https://npm.io/package/modesl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
