How to use the electrode-react-webapp.ReactWebapp.makeRouteHandler function in electrode-react-webapp

To help you get started, we’ve selected a few electrode-react-webapp 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 electrode-io / electrode / packages / subapp-server / lib / setup-hapi-routes.js View on Github external
let options = {};
        if (Array.isArray(x)) {
          options = x[1];
          x = x[0];
        }
        // absolute: use as path
        // else: assume dir under srcDir
        // TBD: handle it being a module
        return {
          subapp: subAppsByPath[Path.isAbsolute(x) ? x : Path.resolve(srcDir, x)],
          options
        };
      });
    }

    const routeHandler = ReactWebapp.makeRouteHandler(routeOptions);
    const handler = async (request, h) => {
      try {
        const context = await routeHandler({
          content: { html: "", status: 200, useStream: true },
          mode: "",
          request
        });

        const data = context.result;
        const status = data.status;

        if (status === undefined) {
          return h
            .response(data)
            .type("text/html; charset=UTF-8")
            .code(200);
github electrode-io / electrode / packages / subapp-server / lib / register-routes.js View on Github external
const { route } = r;

    const routeOptions = Object.assign(
      {},
      topOpts,
      _.pick(route, ["pageTitle", "bundleChunkSelector", "templateFile"])
    );

    assert(routeOptions.templateFile, `subapp-server: route ${r.name} must define templateFile`);
    updateFullTemplate(r.dir, routeOptions);

    const chunkSelector = resolveChunkSelector(routeOptions);

    routeOptions.__internals = { chunkSelector };

    const routeHandler = ReactWebapp.makeRouteHandler(routeOptions);

    const handler = async (request, h) => {
      try {
        const context = await routeHandler({
          content: { html: "", status: 200, useStream: true },
          mode: "",
          request
        });
        const data = context.result;
        const status = data.status;

        if (status === undefined) {
          return h
            .response(data)
            .type("text/html; charset=UTF-8")
            .code(200);

electrode-react-webapp

Hapi plugin that provides a default React web app template

Apache-2.0
Latest version published 1 year ago

Package Health Score

64 / 100
Full package analysis

Popular electrode-react-webapp functions