Skip to content

Instantly share code, notes, and snippets.

@AaronV
Created January 26, 2017 17:20
Show Gist options
  • Save AaronV/81bfb4c818d93e353a1a5a55f9c20d7c to your computer and use it in GitHub Desktop.
Save AaronV/81bfb4c818d93e353a1a5a55f9c20d7c to your computer and use it in GitHub Desktop.
Demandware Controller -> Pipeline passthrough service
/*
Run with:
PassthroughService.pass(exports, "MyPipelineName", [
"myPipelineMethod",
...
]);
*/
var Pipeline = require('dw/system/Pipeline');
function PassthroughService() {
function pass(exports, pipelineName, nodeArray) {
for (var i = 0; i < nodeArray.length; i++) {
var node = nodeArray[i];
exports[node] = executePipeline(pipelineName, node);
exports[node].public = true;
}
}
function executePipeline(pipelineName, node) {
return function() {
Pipeline.execute(pipelineName + "-" + node);
};
}
return {
pass: pass
};
}
module.exports = new PassthroughService();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment