Decode Node's JSON response into arbitrary .NET type. Add VS stuff.

This commit is contained in:
SteveSandersonMS
2015-11-05 22:05:43 +00:00
parent 52953c5fe9
commit 54aad643c8
19 changed files with 213 additions and 26 deletions

View File

@@ -14,15 +14,15 @@ var server = http.createServer(function(req, res) {
if (!func) {
throw new Error('The module "' + resolvedPath + '" has no export named "' + bodyJson.exportedFunctionName + '"');
}
var hasSentResult = false;
var callback = function(errorValue, successValue) {
if (!hasSentResult) {
hasSentResult = true;
if (errorValue) {
res.status(500).send(errorValue);
} else if (typeof successValue === 'object') {
// Arbitrary object - JSON-serialize it
} else if (typeof successValue !== 'string') {
// Arbitrary object/number/etc - JSON-serialize it
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(successValue));
} else {