How to use webiny-compose - 9 common examples

To help you get started, we’ve selected a few webiny-compose 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 webiny / webiny-js / packages / webiny-client-cms / src / admin / widgets / imageWithText / index.js View on Github external
if (value && oldValue) {
                    const update = app.graphql.generateUpdate("Image", fields);
                    return update({ variables: { id: oldValue.id, data: value } }).then(
                        ({ data }) => finish({ value: data })
                    );
                }
                next();
            },
            // Insert new image
            ({ value }, next, finish) => {
                const create = app.graphql.generateCreate("Image", fields);
                create({ variables: { data: value } }).then(({ data }) => finish({ value: data }));
            }
        ];

        compose(flow)({ value, oldValue: _.get(props.widget, "data.image") }).then(({ value }) =>
            onChange(value)
        );
    }
}
github webiny / webiny-js / packages / webiny-api / src / middleware / endpoint.js View on Github external
export default (options: EndpointMiddlewareOptions = {}) => {
    // Endpoint hooks in form of a middleware
    const beforeApiMethodMiddleware = compose(_.get(options, "beforeApiMethod", []));
    const afterApiMethodMiddleware = compose(_.get(options, "afterApiMethod", []));

    return async (
        params: {
            req: express$Request,
            res: express$Response,
            versioning: Function,
            response: Object
        },
        next: Function
    ) => {
        const { req, res, versioning } = params;
        const log = debug("api:endpoint");
        log(`Trying to match an endpoint: %o`, req.method + " " + req.path);
        const reqVersion = versioning(req);
github webiny / webiny-js / webiny-app-cms / src / admin / widgets / pageEditor / image / index.js View on Github external
if (value && oldValue) {
                    const update = app.graphql.generateUpdate("Image", fields);
                    return update({ variables: { id: oldValue.id, data: value } }).then(
                        ({ data }) => finish({ value: data })
                    );
                }
                next();
            },
            // Insert new image
            ({ value }, next, finish) => {
                const create = app.graphql.generateCreate("Image", fields);
                create({ variables: { data: value } }).then(({ data }) => finish({ value: data }));
            }
        ];

        compose(flow)({ value, oldValue: _.get(props.widget, "data.image") }).then(({ value }) =>
            onChange(value)
        );
    }
}
github webiny / webiny-js / packages / webiny-api / src / api.js View on Github external
hooks.push(app[hook]);
            }
        });

        if (this.config.hooks && this.config.hooks[hook]) {
            hooks.push(this.config.hooks[hook]);
        }

        const params: Object = { api: this };

        if (hook === "init") {
            params.schema = schema;
        }

        try {
            await compose(hooks)(params);
        } catch (e) {
            this.log(`An error occurred in the "${hook}" process:\n${e.stack}`, "error");
            process.exit(1);
        }
    }
}
github webiny / webiny-js / packages / webiny-app / src / app / index.js View on Github external
async setup() {
        debug("Started setup");
        this.config = await this.configLoader();
        await compose(this.configurators)({ app: this });
        this.initialized = true;
        debug("Finished setup");
    }
}
github webiny / webiny-js / packages-client / webiny-client / src / app / index.js View on Github external
async setup() {
        debug("Started setup");
        this.config = await this.configLoader();
        await compose(this.configurators)({ app: this });
        this.initialized = true;
        debug("Finished setup");
    }
}
github webiny / webiny-js / packages-client / webiny-client / src / router / Router.js View on Github external
configure(config: Object) {
        this.config = { ...config };
        this.history = config.history;
        this.middleware = compose(config.middleware);
        this.match = null;
    }
github webiny / webiny-js / packages / webiny-api / src / graphql / middleware.js View on Github external
variables: context.event.body.variables,
            operationName: context.event.body.operationName
        };
        next();
    },
    securityMiddleware(),
    graphqlMiddleware(),
    (context, next, finish) => {
        if (context.output.errors) {
            context.output.errors = context.output.errors.map(formatError);
        }
        finish(context);
    }
];

export default compose(middleware);
github webiny / webiny-js / packages / webiny-react-router / src / Router.js View on Github external
configure(config: Object) {
        this.config = { ...config };
        this.history = config.history;
        this.middleware = compose(config.middleware);

        if (!this.history) {
            this.history = createBrowserHistory();
        }
    }

webiny-compose

This library composes a middleware for processing arbitrary data.

MIT
Latest version published 6 years ago

Package Health Score

66 / 100
Full package analysis

Popular webiny-compose functions