Created
January 26, 2017 17:20
-
-
Save AaronV/81bfb4c818d93e353a1a5a55f9c20d7c to your computer and use it in GitHub Desktop.
Demandware Controller -> Pipeline passthrough service
This file contains hidden or 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
/* | |
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