Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server.ext('onPreHandler', (request, reply) => {
const settings = request.route.settings.plugins[name];
if (settings) {
//console.log(Util.inspect(`flow-loader.plugin [${settings.name}] -> ${JSON.stringify(request.path)} `, { colors: true })); // TODO: REMOVE!!!!
const data = { request: new NoFlo.IP('data', request, { scope: request.id }) };
if (_.isArray(settings.consumes)) {
settings.consumes.forEach((service) => {
data[service] = new NoFlo.IP('data', server.app[service], { scope: request.id });
});
}
const graph = NoFlo.asCallback(settings.name, { loader });
const promisedGraph = Util.promisify(graph);
promisedGraph(data)
.then((result) => {
if (!result) {
return reply.continue();
}
if (result.error) {
throw new Error(new Boom.internal(result.error));
}
request.plugins[name] = result.out;
return reply.continue();
})
.catch((err) => {
console.error(err);