Skip to content

Instantly share code, notes, and snippets.

@paulwsmith
Created June 11, 2015 15:56
Show Gist options
  • Save paulwsmith/26f8f84ae892fe11b639 to your computer and use it in GitHub Desktop.
Save paulwsmith/26f8f84ae892fe11b639 to your computer and use it in GitHub Desktop.
Local plugin runner exploration
/* 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);
});
/* 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(...) {
};
}
// 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