any2api-generator-soap
Advanced tools
Comparing version 0.1.14 to 0.1.16
@@ -107,3 +107,3 @@ var path = require('path'); | ||
def.wsdl_type_ns_prefix = 'xsd'; | ||
} else if (S(def.type).toLowerCase().contains('byte')) { | ||
} else if (S(def.type).toLowerCase().contains('binary')) { | ||
def.wsdl_type_name = 'base64Binary'; | ||
@@ -154,2 +154,3 @@ def.wsdl_type_ns_prefix = 'xsd'; | ||
item.wsdl_service_name = item.wsdl_name + 'Service'; | ||
item.wsdl_url_path = item.wsdl_service_name + '/' + item.wsdl_port_name; | ||
@@ -156,0 +157,0 @@ enrichSchema(item.parameters_schema, item.wsdl_name); |
{ | ||
"name": "any2api-generator-soap", | ||
"version": "0.1.14", | ||
"version": "0.1.16", | ||
"author": "Johannes Wettinger <mail@jojow.de>", | ||
@@ -5,0 +5,0 @@ "description": "SOAP/WSDL API implementation generator for any2api", |
@@ -15,4 +15,10 @@ var path = require('path'); | ||
var preInvokeCode = process.env.PRE_INVOKE || ''; | ||
var preInvokeTplPath = path.join(__dirname, 'pre-invoke.js.tpl'); | ||
var preInvokeScrPath = path.join(__dirname, 'pre-invoke.js'); | ||
fs.writeFileSync(preInvokeScrPath, _.template(fs.readFileSync(preInvokeTplPath, 'utf8'))({ code: preInvokeCode }), 'utf8'); | ||
var preInvoke = require('./pre-invoke'); | ||
var port = process.env.PORT || 3000; | ||
@@ -40,5 +46,7 @@ var baseAddress = process.env.BASE_ADDRESS || 'http://0.0.0.0:' + port; | ||
var item = apiSpec.executables[executableName]; | ||
if (!item) item = apiSpec.invokers[invokerName]; | ||
var executable = apiSpec.executables[executableName]; | ||
var invoker = apiSpec.invokers[invokerName]; | ||
var item = executable || invoker; | ||
//TODO: run util.persistEmbeddedExecutable _if_ invokerName && input.executable | ||
@@ -71,34 +79,42 @@ | ||
debug('instance', instance); | ||
// Invoke executable | ||
util.invokeExecutable({ apiSpec: apiSpec, | ||
instance: instance, | ||
executable_name: executableName, | ||
invoker_name: invokerName }, function(err, instance) { | ||
preInvoke(instance, executable, invoker, function(err, instance) { | ||
if (err) return callback(err); | ||
// Map results | ||
var output = { instance: instance, results: {} }; | ||
debug('instance', instance); | ||
_.each(instance.results, function(value, name) { | ||
var resultDef = item.results_schema[name]; | ||
// Invoke executable | ||
util.invokeExecutable({ apiSpec: apiSpec, | ||
instance: instance, | ||
executable_name: executableName, | ||
invoker_name: invokerName }, function(err, instance) { | ||
if (err) return callback(err); | ||
if (!resultDef) return; | ||
//TODO: we're affected by this bug: https://github.com/vpulim/node-soap/issues/613 | ||
// errors that occur here are not sent back to the client as SOAP faults | ||
var wsdlName = item.results_schema[name].wsdl_name; | ||
if (S(resultDef.type).toLowerCase().contains('json')) { | ||
output.results[wsdlName] = JSON.stringify(value, null, 2); | ||
} else if (S(resultDef.type).toLowerCase().contains('byte') && Buffer.isBuffer(value)) { | ||
output.results[wsdlName] = value.toString('base64'); | ||
} else { | ||
output.results[wsdlName] = value; | ||
} | ||
}); | ||
// Map results | ||
var output = { instance: instance, results: {} }; | ||
delete instance.parameters; | ||
delete instance.results; | ||
_.each(instance.results, function(value, name) { | ||
var resultDef = item.results_schema[name] || {}; | ||
resultDef.type = resultDef.type || ''; | ||
callback(null, output); | ||
var wsdlName = resultDef.wsdl_name || S(name).camelize().stripPunctuation().s; | ||
if (S(resultDef.type).toLowerCase().contains('json')) { | ||
output.results[wsdlName] = JSON.stringify(value, null, 2); | ||
} else if (S(resultDef.type).toLowerCase().contains('binary') && Buffer.isBuffer(value)) { | ||
output.results[wsdlName] = value.toString('base64'); | ||
} else if (S(resultDef.type).toLowerCase().contains('xml')) { | ||
output.results[wsdlName]['$xml'] = value; | ||
} else { | ||
output.results[wsdlName] = value; | ||
} | ||
}); | ||
delete instance.parameters; | ||
delete instance.results; | ||
callback(null, output); | ||
}); | ||
}); | ||
@@ -196,3 +212,3 @@ }); | ||
soap.listen(server, '/' + item.wsdl_service_name + '/' + item.wsdl_port_name, port, wsdl); | ||
soap.listen(server, '/' + item.wsdl_url_path, port, wsdl); | ||
}); | ||
@@ -199,0 +215,0 @@ }); |
{ | ||
"name": "soap-node-api-impl", | ||
"name": "soap-api-impl", | ||
"version": "1.0.0", | ||
@@ -4,0 +4,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
26658
12
398
20