How to use the noflo.asCallback function in noflo

To help you get started, we’ve selected a few noflo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samtecspg / articulate / api / plugins / flow-loader.plugin.js View on Github external
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);

noflo

Flow-Based Programming environment for JavaScript

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis