How to use the pupperender.makeMiddleware function in pupperender

To help you get started, we’ve selected a few pupperender 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 LasaleFamine / http-server-pwa / src / index.js View on Github external
const HOST = opt.h || opt.host || getStHost();
	const FALLINDEX = opt.f || opt.fallback || 'index.html';
	const DEBUG = opt.d || opt.debug || false;
	const LOCALHTTPS = opt.s || opt.https || false;
	const CACHE = opt.c || opt.cache || false;
	const CACHE_TTL = opt.cacheTTL || 3600;
	const SSL = opt.ssl || false;
	const IS_DEV = process.env.NODE_ENV !== 'production';

	const app = express();

	// Don't redirect if the hostname is `localhost` or `127.0.0.1`
	app.use(redirectToHTTPS(LOCALHTTPS ? [] : [/localhost|127.0.0.1/]));

	app.use(loggerMiddleware(DEBUG));
	app.use(pupperender.makeMiddleware({debug: DEBUG, useCache: CACHE, cacheTTL: CACHE_TTL}));
	app.use(express.static(ROOT));
	app.use(fallback(FALLINDEX, {root: ROOT}));

	const sslCert = SSL && IS_DEV ?
		await certificate.default('pwa-server', {installCertutil: true}) : null;

	return new Promise(resolve => {
		const server = sslCert ? createServer(sslCert, app) : app;
		const res = server.listen(
			PORT,
			HOST,
			() => {
				log.green('HSP started 🤘');
				log.info(
					`Path: ${ROOT} \nHost: ${sslCert ? 'https' : 'http'}://${HOST}:${PORT} \nFalling on: ${join(ROOT, FALLINDEX)}`
				);

pupperender

ExpressJs middleware for rendering PWA to bots using Puppeteer.

MIT
Latest version published 3 years ago

Package Health Score

39 / 100
Full package analysis

Popular pupperender functions