How to use @shopify/sewing-kit-koa - 3 common examples

To help you get started, we’ve selected a few @shopify/sewing-kit-koa 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 Shopify / quilt / packages / react-server / src / render / render.tsx View on Github external
error.message}`;

      logger.log(errorMessage);
      ctx.status = StatusCode.InternalServerError;

      // eslint-disable-next-line no-process-env
      if (process.env.NODE_ENV === 'development') {
        ctx.body = errorMessage;
      } else {
        ctx.throw(StatusCode.InternalServerError, error);
      }
    }
  }

  return compose([
    sewingKitMiddleware({assetPrefix, manifestPath}),
    renderFunction,
  ]);
}
github Shopify / quilt / packages / react-server / src / render / render.tsx View on Github external
async function renderFunction(ctx: Context) {
    const logger = getLogger(ctx) || console;
    const assets = getAssets(ctx);

    const networkManager = new NetworkManager({
      headers: ctx.headers,
      cookies: ctx.request.headers.cookie || '',
    });
    const htmlManager = new HtmlManager();
    const asyncAssetManager = new AsyncAssetManager();
    const hydrationManager = new HydrationManager();

    function Providers({children}: {children: React.ReactElement}) {
      return (
        
          
            
              {children}
github Shopify / quilt / packages / graphql-persisted / src / koa-middleware.ts View on Github external
const {id} = body.extensions.persisted;

    if (body.query != null) {
      if (
        cacheMissBehavior === CacheMissBehavior.SendAndStore &&
        cache != null
      ) {
        await cache.set(id, body.query);
      }

      await next();
      return;
    }

    const assets = getAssets(ctx);

    const operationFromManifest =
      assets != null && assets.graphQLSource != null
        ? await assets.graphQLSource(id)
        : undefined;

    if (typeof operationFromManifest === 'string' && cache != null) {
      cache.set(id, operationFromManifest);
    }

    const operation = operationFromManifest || (cache && (await cache.get(id)));

    if (typeof operation === 'string') {
      body.query = operation;
      await next();
    } else {

@shopify/sewing-kit-koa

Easily access Sewing Kit assets from a Koa server

MIT
Latest version published 1 year ago

Package Health Score

79 / 100
Full package analysis

Similar packages