The modesl-wrapper library provides you with a type-safe wrapper around modesl that allows you to listen on ESL events and log, save to JSON file, and apply your callbacks to selected events. It also provides with few pre-cooked FreeSWITCH background API commands like reloadxml, uuid_kill and others.
Install it with npm or yarn from Github:
yarn add https://github.com/matteolc/modesl-wrapper.git
Import and create a new ESL wrapper instance:
import { ESLWrapper, FSEvent, createESLWrapper } from 'modesl-wrapper';
const esl = createESLWrapper(ESLWrapper, {
logger,
conninfo: {
host,
port,
secret,
},
cblist,
savelist,
loglist,
});
esl.listen();
The ESL wrapper accepts the following options:
loggerrequired A logger function that has at leastinfo,debuganderrormethodsconninforequired ESL connection informationcblistoptional A list of callbacks for selected events. Each object incblistmust have aneventandapplykey. Theeventkey indicates which event you would like to apply the function defined in theapplykey. For instance:
import { FSEvent } from 'modesl-wrapper';
function doSomething(event: any) {
logger.debug(JSON.stringify(event));
}
cblist = [
{
event: FSEvent.Channel.HEARTBEAT,
apply: doSomething,
},
]
savelistoptional A list of events that you would like to save as JSON to file. Files will be saved in thedata/eslfolder of your project root, divided by year, month, day and hour. For instance:
savelist = [FSEvent.Channel.HANGUP_COMPLETE]
loglistoptional A list of events that you would like to log with theloggerprovided. For instance:
loglist = [FSEvent.Channel.HANGUP_COMPLETE]
ReloadXMLUUIDGetVarUUIDKillUUIDTransferUUIDSetvarMultiUUIDSetvar
This library is distributed under the MIT license.