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