Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @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();
};
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()}
// @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);
};
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();
};
// @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);
};
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;
// @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);
};
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;
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();
};
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();
};