How to use mwp-core - 6 common examples

To help you get started, we’ve selected a few mwp-core 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 meetup / meetup-web-platform / packages / mwp-core / src / renderers / server-render.jsx View on Github external
const requestLanguage = request.getLanguage();

	return {
		apiUrl: API_ROUTE_PATH,
		baseUrl: host,
		basename: requestLanguage === 'en-US' ? '' : `/${requestLanguage}`, // basename is the 'base path' for the application - usually a localeCode
		enableServiceWorker,
		requestLanguage,
		supportedLangs: server.settings.app.supportedLangs,
		initialNow: new Date().getTime(),
		isProdApi: server.settings.app.api.isProd,
		isQL: parseMemberCookie(state).ql === 'true',
		memberId: parseMemberCookie(state).id, // deprecated, use member.id
		// the member cookie is not structured the same way as the member object returned from /member/self
		// be careful relying on it to have the same properties downstream
		member: parseMemberCookie(state),
		variants: getVariants(state),
		entryPath: url.pathname, // the path that the user entered the app on
		media: getMedia(userAgent, userAgentDevice),
		browserId: parseBrowserIdCookie(state),
		clientIp,
		siftSessionId: parseSiftSessionCookie(state),
		isBot: isBot(request.headers['user-agent']),
	};
};
github meetup / meetup-web-platform / packages / mwp-core / src / renderers / server-render.jsx View on Github external
initializeStore(resolvedRoutes).then(store => {
				// the initial addFlags call will only be key'd by member ID
				return addFlags(store, { id: parseMemberCookie(request.state).id })
					.then(() => populateStore(store))
					.then(
						store =>
							// create tracer and immediately invoke the resulting function.
							// trace should start before rendering, finish after rendering
							newrelic.createTracer('serverRender', getRouterRenderer)({
								request,
								h,
								appContext,
								routes: resolvedRoutes,
								store,
								scripts,
								cssLinks,
							}) // immediately invoke callback
					);
			})
github meetup / meetup-web-platform / packages / mwp-core / src / renderers / server-render.jsx View on Github external
const host = `${requestProtocol}://${domain}`;
	const userAgent = headers['user-agent'];
	const userAgentDevice = headers['x-ua-device'] || ''; // set by fastly
	const requestLanguage = request.getLanguage();

	return {
		apiUrl: API_ROUTE_PATH,
		baseUrl: host,
		basename: requestLanguage === 'en-US' ? '' : `/${requestLanguage}`, // basename is the 'base path' for the application - usually a localeCode
		enableServiceWorker,
		requestLanguage,
		supportedLangs: server.settings.app.supportedLangs,
		initialNow: new Date().getTime(),
		isProdApi: server.settings.app.api.isProd,
		isQL: parseMemberCookie(state).ql === 'true',
		memberId: parseMemberCookie(state).id, // deprecated, use member.id
		// the member cookie is not structured the same way as the member object returned from /member/self
		// be careful relying on it to have the same properties downstream
		member: parseMemberCookie(state),
		variants: getVariants(state),
		entryPath: url.pathname, // the path that the user entered the app on
		media: getMedia(userAgent, userAgentDevice),
		browserId: parseBrowserIdCookie(state),
		clientIp,
		siftSessionId: parseSiftSessionCookie(state),
		isBot: isBot(request.headers['user-agent']),
	};
};
github meetup / meetup-web-platform / packages / mwp-core / src / renderers / server-render.jsx View on Github external
info.remoteAddress;
	const host = `${requestProtocol}://${domain}`;
	const userAgent = headers['user-agent'];
	const userAgentDevice = headers['x-ua-device'] || ''; // set by fastly
	const requestLanguage = request.getLanguage();

	return {
		apiUrl: API_ROUTE_PATH,
		baseUrl: host,
		basename: requestLanguage === 'en-US' ? '' : `/${requestLanguage}`, // basename is the 'base path' for the application - usually a localeCode
		enableServiceWorker,
		requestLanguage,
		supportedLangs: server.settings.app.supportedLangs,
		initialNow: new Date().getTime(),
		isProdApi: server.settings.app.api.isProd,
		isQL: parseMemberCookie(state).ql === 'true',
		memberId: parseMemberCookie(state).id, // deprecated, use member.id
		// the member cookie is not structured the same way as the member object returned from /member/self
		// be careful relying on it to have the same properties downstream
		member: parseMemberCookie(state),
		variants: getVariants(state),
		entryPath: url.pathname, // the path that the user entered the app on
		media: getMedia(userAgent, userAgentDevice),
		browserId: parseBrowserIdCookie(state),
		clientIp,
		siftSessionId: parseSiftSessionCookie(state),
		isBot: isBot(request.headers['user-agent']),
	};
};
github meetup / meetup-web-platform / packages / mwp-consumer / src / server-app.js View on Github external
import { makeRenderer$ as makeServerRenderer$ } from 'mwp-core/lib/renderers/server-render';
import makeRootReducer from 'mwp-store/lib/reducer';

const routes = require('./app/routes').default;
const reducer = makeRootReducer();

// the server-side `renderRequest$` Observable will take care of wrapping
// the react application with the full HTML response markup, including ``,
// `` and its contents, and the `
github meetup / meetup-web-platform / packages / mwp-test-utils / src / mocks.js View on Github external
export const getMockRenderRequestMap = () => {
	const basename = '';

	const renderRequest$ = makeRenderer(routes, reducer, [], basename, [
		clientFilename,
	]);

	return {
		'en-US': renderRequest$,
	};
};

mwp-core

Core utilities for MWP apps

MIT
Latest version published 7 months ago

Package Health Score

42 / 100
Full package analysis

Similar packages