Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/LasaleFamine/pupperender
ExpressJs middleware for rendering PWA to bots using Puppeteer.
https://github.com/LasaleFamine/pupperender
bot-render expressjs hacktoberfest middleware puppeteer rendering
Last synced: 30 days ago
JSON representation
ExpressJs middleware for rendering PWA to bots using Puppeteer.
- Host: GitHub
- URL: https://github.com/LasaleFamine/pupperender
- Owner: LasaleFamine
- License: mit
- Created: 2017-11-02T13:26:59.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-12T20:38:47.000Z (10 months ago)
- Last Synced: 2024-04-15T01:17:02.932Z (8 months ago)
- Topics: bot-render, expressjs, hacktoberfest, middleware, puppeteer, rendering
- Language: JavaScript
- Homepage:
- Size: 2.14 MB
- Stars: 117
- Watchers: 7
- Forks: 12
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-puppeteer - pupperender - Express middleware that renders PWAs for bots using puppeteer. (Rendering and web scraping)
- awesome-puppeteer-zh - pupperender - 使用puppeteer为机器人提供 渲染PWA的Express中间件. (渲染和网页抓取 / 贡献)
README
# pupperender
[![npm](https://img.shields.io/npm/v/pupperender.svg?style=flat)](https://github.com/LasaleFamine/pupperender)
[![Build Status](https://travis-ci.com/LasaleFamine/pupperender.svg?branch=master)](https://travis-ci.com/LasaleFamine/pupperender) [![Build status](https://ci.appveyor.com/api/projects/status/7adc8sxp20kgw10v?svg=true)](https://ci.appveyor.com/project/LasaleFamine/pupperender) [![codecov](https://codecov.io/gh/LasaleFamine/pupperender/badge.svg?branch=master)](https://codecov.io/gh/LasaleFamine/pupperender?branch=master)> ExpressJs middleware for rendering PWA to bots using Puppeteer
This is a middleware for ExpressJs that uses Puppeter for render the page requested by "indexing" bots (and not).
This is a fork of the [rendertron-middleware](https://www.npmjs.com/package/rendertron-middleware) but using [Puppeter](https://github.com/GoogleChrome/puppeteer) instead of [Rendertron](https://github.com/GoogleChrome/rendertron/), without needing another server to render the app. I have made some changes for my personal use (like removing the inject ShadyDOM option).
## Install
```
$ yarn add pupperender
```## Usage
```js
const express = require('express');
const pupperender = require('pupperender');const app = express();
app.use(pupperender.makeMiddleware({}));
app.use(express.static('files'));
app.listen(8080);
```## Configuration
Like [rendertron-middleware](https://www.npmjs.com/package/rendertron-middleware) I decided to expose a `makeMiddleware` function that takes a configuration object with the following
properties:| Property | Default | Description |
| -------- | ------- | ----------- |
| `userAgentPattern` | A set of known bots that benefit from pre-rendering. [Full list.](https://github.com/LasaleFamine/pupperender/blob/master/src/index.js) | RegExp for matching requests by User-Agent header. |
| `excludeUrlPattern` | A set of known static file extensions. [Full list.](https://github.com/LasaleFamine/pupperender/blob/master/src/index.js) | RegExp for excluding requests by the path component of the URL. |
| `timeout` | `11000` | Millisecond timeout for waiting the page to load. Used by Puppeter. See also the [Puppeter waitFor()](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitforselectororfunctionortimeout-options-args) |
| `debug` | `false` | DEBUG flag to show some logs |
| `useCache` | `false` | If the puppeterized content should be cached to speed up subsequent requests. |
| `cacheTTL` | `3600` | Seconds until cached content is disregarded and puppeterized again. Only considered when `useCache` is `true`. |## License
MIT © [LasaleFamine](https://godev.space)