How to use the webiny-plugins.registerPlugins function in webiny-plugins

To help you get started, we’ve selected a few webiny-plugins 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 / demo-api / src / install / install.js View on Github external
// @flow
import config from "./../configs";
import { registerPlugins } from "webiny-plugins";
import install from "webiny-install";

import securityPlugins from "webiny-api-security/install/plugins";
import cmsPlugins from "webiny-api-cms/install/plugins";

registerPlugins(securityPlugins, cmsPlugins);

export default async () => {
    await install({
        config: await config(),
        cms: { copyFiles: true, copyFilesTo: "../../__static" }, // TODO: handled by the CLI install
        security: { admin: { email: "admin@webiny.com", password: "12345678" } }
    });
    process.exit();
};
github webiny / webiny-js / packages / webiny-cli / src / init / template / packages / admin / src / App.js View on Github external
import { hot } from "react-hot-loader";
import React, { cloneElement, Fragment } from "react";
import { UiProvider } from "webiny-app/context/ui";
import { registerPlugins, getPlugins } from "webiny-plugins";
import { Theme as AdminTheme } from "webiny-admin";
import { CmsProvider } from "webiny-app-cms/context";
import { CircularProgress } from "webiny-ui/Progress";
import { Security } from "webiny-app-security/components";
import Login from "webiny-app-security/admin/views/Login";
import myTheme from "theme";
import "./App.scss";
import plugins from "./plugins";

// Register all plugins
registerPlugins(plugins);

// Execute `init` plugins, they may register more plugins dynamically
getPlugins("webiny-init").forEach(plugin => plugin.callback());

const App = () => {
    return (
        /* UiProvider is a simple provider for UI state (dialogs, snackbars, dark theme, ...). */
        
            {/* Security components handles user authentication. */}
            
                {({ initialLoad, authenticated, notAuthenticated }) => (
                    
                        {/* AdminTheme handles the Dark/Light theme switching and initialization. */}
                        
                            {/* Render a loader during initial load of user data */}
                            {initialLoad()}
github webiny / webiny-js / packages / demo-service-security / src / handler.js View on Github external
// @flow
import { registerPlugins } from "webiny-plugins";
import { createHandler as createBaseHandler } from "webiny-api";
import createConfig from "demo-service-config";
import plugins from "./plugins";

registerPlugins(plugins);

export const handler = async (event: Object, context: Object) => {
    const config = await createConfig();
    const apolloHandler = await createBaseHandler(config);
    return apolloHandler(event, context);
};
github webiny / webiny-js / packages / webiny-app-page-builder / src / admin / index.js View on Github external
if (route.path.startsWith("/page-builder/pages") && !loaded.render) {
        const renderPlugins = await import("webiny-app-page-builder/render/presets/default");
        registerPlugins(renderPlugins.default);

        loaded.render = true;
    }

    // If we are on the Editor route, import plugins required to render both editor and preview.
    if (route.path.startsWith("/page-builder/editor") && !loaded.editor) {
        const plugins = await Promise.all(
            [
                import("webiny-app-page-builder/editor/presets/default"),
                !loaded.render ? import("webiny-app-page-builder/render/presets/default") : null
            ].filter(Boolean)
        );
        registerPlugins(plugins.map(p => p.default));

        loaded.editor = true;
        loaded.render = true;
    }

    next();
};
github webiny / webiny-js / packages / demo-service-headless / src / handler.js View on Github external
// @flow
import { registerPlugins } from "webiny-plugins";
import { createHandler as createBaseHandler } from "webiny-api";
import servicePlugins from "webiny-api/plugins/service";
import securityPlugins from "webiny-api-security/plugins/service";
import headlessPlugins from "webiny-api-headless/plugins";
import createConfig from "demo-service-config";

registerPlugins(servicePlugins, securityPlugins, headlessPlugins);

/**
 * `createHandler(context)` - function which returns an actual handler function.
 */
export const createHandler = async (context: Object) => {
    const config = await createConfig(context);
    return await createBaseHandler(config);
};
github webiny / webiny-js / packages / webiny-app-page-builder / src / admin / index.js View on Github external
export const lazyLoadMiddleware = () => async (params: Object, next: Function) => {
    const { route } = params;

    // If we are on pages list route, import plugins required to render the page content.
    if (route.path.startsWith("/page-builder/pages") && !loaded.render) {
        const renderPlugins = await import("webiny-app-page-builder/render/presets/default");
        registerPlugins(renderPlugins.default);

        loaded.render = true;
    }

    // If we are on the Editor route, import plugins required to render both editor and preview.
    if (route.path.startsWith("/page-builder/editor") && !loaded.editor) {
        const plugins = await Promise.all(
            [
                import("webiny-app-page-builder/editor/presets/default"),
                !loaded.render ? import("webiny-app-page-builder/render/presets/default") : null
            ].filter(Boolean)
        );
        registerPlugins(plugins.map(p => p.default));

        loaded.editor = true;
        loaded.render = true;
github webiny / webiny-js / packages / webiny-cli / src / init / template / packages / api / src / handler.js View on Github external
// @flow
import { registerPlugins } from "webiny-plugins";
import { createHandler as createBaseHandler } from "webiny-api";
import createConfig from "./configs";
import plugins from "./plugins";

registerPlugins(plugins);

/**
 * `createHandler(context)` - function which returns an actual handler function.
 */
export const createHandler = async (context: Object) => {
    const config = await createConfig(context);
    return await createBaseHandler(config);
};
github webiny / webiny-js / packages / webiny-app-page-builder / src / admin / components / EditorPluginsLoader.js View on Github external
async function loadPlugins() {
        // If we are on pages list route, import plugins required to render the page content.
        if (location.pathname.startsWith("/page-builder/pages") && !loaded.render) {
            const renderPlugins = await import("webiny-app-page-builder/render/presets/default");
            registerPlugins(renderPlugins.default);

            globalState.render = true;
            setLoaded({ render: true });
        }

        // If we are on the Editor route, import plugins required to render both editor and preview.
        if (location.pathname.startsWith("/page-builder/editor") && !loaded.editor) {
            const plugins = await Promise.all(
                [
                    import("webiny-app-page-builder/editor/presets/default"),
                    !loaded.render ? import("webiny-app-page-builder/render/presets/default") : null
                ].filter(Boolean)
            );
            registerPlugins(plugins.map(p => p.default));

            globalState.editor = true;
github webiny / webiny-js / packages / webiny-cli / src / init / template / packages / api / src / install.js View on Github external
import config from "./configs";
import { registerPlugins } from "webiny-plugins";
import installer from "webiny-install";

import securityPlugins from "webiny-api-security/install/plugins";
import cmsPlugins from "webiny-api-cms/install/plugins";

registerPlugins(securityPlugins, cmsPlugins);

export const install = async (context = {}) => {
    await installer({ ...context, config: await config() });
    process.exit();
};
github webiny / webiny-js / packages / webiny-cli / src / init / template / packages / api / src / install / install.js View on Github external
import config from "./../configs";
import { registerPlugins } from "webiny-plugins";
import install from "webiny-install";

import securityPlugins from "webiny-api-security/install/plugins";
import cmsPlugins from "webiny-api-cms/install/plugins";

registerPlugins(securityPlugins, cmsPlugins);

export default async () => {
    await install({ config: await config() });
    process.exit();
};

webiny-plugins

A simple registry that stores all plugins in a shared object.

MIT
Latest version published 5 years ago

Package Health Score

66 / 100
Full package analysis