partial support for twilio urlencoded parser

This commit is contained in:
AJ ONeal 2017-07-01 03:11:47 +00:00
parent bd497902f0
commit 891489e359
1 changed files with 20 additions and 10 deletions

View File

@ -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 + "'] "