How to use the @webiny/api.PluginsContainer function in @webiny/api

To help you get started, we’ve selected a few @webiny/api 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 / examples / functions / code / api-service-security / src / handler.js View on Github external
// @flow
import { createHandler, PluginsContainer } from "@webiny/api";
import createConfig from "service-config";
import servicePlugins from "@webiny/api/plugins/service";
import securityPlugins from "@webiny/api-security/plugins";

const plugins = new PluginsContainer([servicePlugins, securityPlugins]);

let apolloHandler;

export const handler = async (event: Object, context: Object) => {
    if (!apolloHandler) {
        const config = await createConfig();
        const { handler } = await createHandler({ plugins, config });
        apolloHandler = handler;
    }

    return apolloHandler(event, context);
};
github webiny / webiny-js / examples / functions / code / api-service-files / src / handler.js View on Github external
// @flow
import { createHandler, PluginsContainer } from "@webiny/api";
import createConfig from "service-config";

import servicePlugins from "@webiny/api/plugins/service";
import securityPlugins from "@webiny/api-security/plugins/service";
import filesPlugins from "@webiny/api-files/plugins";

const plugins = new PluginsContainer([servicePlugins, securityPlugins, filesPlugins]);

let apolloHandler;

export const handler = async (event: Object, context: Object) => {
    if (!apolloHandler) {
        const config = await createConfig();
        const { handler } = await createHandler({ plugins, config });
        apolloHandler = handler;
    }

    return apolloHandler(event, context);
};
github webiny / webiny-js / examples / functions / api-service-headless / src / handler.js View on Github external
// @flow
import { createHandler, PluginsContainer } 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 "service-config";

const plugins = new PluginsContainer([servicePlugins, securityPlugins, headlessPlugins]);

export const handler = async (context: Object) => {
    const config = await createConfig(context);
    return await createHandler({ config, plugins });
};
github webiny / webiny-js / components / serverless-apollo-service / boilerplate / handler.js View on Github external
export const handler = async (event, context) => {
    if (!apolloHandler) {
        const plugins = new PluginsContainer([]);
        const { handler } = await createHandler({ plugins });
        apolloHandler = handler;
    }

    return apolloHandler(event, context);
};
github webiny / webiny-js / components / serverless-apollo-gateway / boilerplate / handler.js View on Github external
export const handler = async (event, context) => {
    if (!apolloHandler) {
        const plugins = new PluginsContainer([]);
        const plugin = plugins.byName("create-apollo-gateway");
        apolloHandler = await plugin.createGateway({ plugins });
    }

    return new Promise((resolve, reject) => {
        apolloHandler(event, context, (error, data) => {
            if (error) {
                return reject(error);
            }

            resolve(data);
        });
    });
};
github webiny / webiny-js / examples / functions / code / api-service-forms / src / handler.js View on Github external
export const handler = async (event: Object, context: Object) => {
    if (!apolloHandler) {
        const config = await createConfig();
        const plugins = new PluginsContainer([
            servicePlugins,
            securityPlugins,
            i18nPlugins,
            formsPlugins
        ]);

        const { handler } = await createHandler({ plugins, config });
        apolloHandler = handler;
    }

    return apolloHandler(event, context);
};
github webiny / webiny-js / examples / functions / code / api-service-page-builder / src / handler.js View on Github external
export const handler = async (event: Object, context: Object) => {
    if (!apolloHandler) {
        const config = await createConfig();
        const plugins = new PluginsContainer([
            securityPlugins,
            i18nPlugins,
            pageBuilderPlugins(config),
            mailchimpPlugins(config),
            gtmPlugins(config),
            cookiePolicyPlugins(config)
        ]);

        const { handler } = await createHandler({ plugins, config });
        apolloHandler = handler;
    }

    return apolloHandler(event, context);
};
github webiny / webiny-js / examples / functions / code / api-service-i18n / src / handler.js View on Github external
export const handler = async (event: Object, context: Object) => {
    if (!apolloHandler) {
        const config = await createConfig();
        const plugins = new PluginsContainer([
            /*securityPlugins,*/ i18nPlugins(config)
        ]);
        const { handler } = await createHandler({ plugins, config });
        apolloHandler = handler;
    }

    return apolloHandler(event, context);
};