Created
June 11, 2015 15:56
-
-
Save paulwsmith/26f8f84ae892fe11b639 to your computer and use it in GitHub Desktop.
Local plugin runner exploration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* DO NOT MODIFY THIS FILE! IT'S FOR LOCAL USE ONLY! */ | |
app.uses(function(req, resp, next) { | |
var httpRequest = require('httpRequest'); | |
httpRequest.setAccessToken(req.headers.accessToken); | |
delete req.headers.accessToken; | |
var eventData = {}; | |
eventData.request = { | |
headers: req.getHeaders(), | |
body: req.getBody() | |
}; | |
var plugin = require('plugin'); | |
plugin.run(eventData); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* DO NOT MODIFY THIS FILE! IT'S FOR LOCAL USE ONLY! */ | |
var accessToken = null; | |
module.exports = function() { | |
this.setAccessToken = function(token) { | |
if (accessToken !== null) { | |
// token already set | |
return; | |
} | |
accessToken = token; | |
}; | |
this.get = function(...) { | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Plugin code goes here | |
exports.run = function(eventData) { | |
var httpRequest = require('httpRequest'); | |
var formId = eventData.body.formId; | |
httpRequest.get('/v1/forms/' + formId + '/records', function(response) { | |
// do something with form records | |
}); | |
} | |
// node appRunner.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment