From 891489e35983933923fabb73cdc6bbf34f937a1b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 1 Jul 2017 03:11:47 +0000 Subject: [PATCH] partial support for twilio urlencoded parser --- lib/apis.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/apis.js b/lib/apis.js index 69690f7..0151d83 100644 --- a/lib/apis.js +++ b/lib/apis.js @@ -430,20 +430,30 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) { } }); - var caps = { - 'com.daplie.tel.twilio': function (/*opts*/) { - if (_twilio) { - return _twilio; - } + function twilioTel(/*opts*/) { + if (_twilio) { + return _twilio; + } - var Twilio = require('twilio'); - _twilio = new Twilio.RestClient(siteConfig['twilio.com'].id, siteConfig['twilio.com'].auth); - return apiDeps.Promise.resolve(_twilio); + var Twilio = require('twilio'); + _twilio = new Twilio.RestClient( + siteConfig['twilio.com'].live.id + , siteConfig['twilio.com'].live.auth + ); + return apiDeps.Promise.resolve(_twilio); + } + + var bodyParserTwilio = require('body-parser').urlencoded({ limit: '4kb', parameterLimit: 25, extended: false }); + var caps = { + 'twilio@daplie.com': twilioTel + , 'com.daplie.tel.twilio': twilioTel // deprecated + , 'twilio.urlencoded@daplie.com': function (req, res, next) { + return bodyParserTwilio(req, res, next); } }; - req.getSiteCapability = function (capname, opts) { + req.getSiteCapability = function (capname, opts, b, c) { if (caps[capname]) { - return caps[capname](opts); + return caps[capname](opts, b, c); } return apiDeps.Promise.reject( new Error("['" + req.clientApiUri + '/' + pkgId + "'] "