All Projects → LasaleFamine → http-server-pwa

LasaleFamine / http-server-pwa

Licence: MIT license
👾 http-server alike but for serving and rendering PWA: pwa-server

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to http-server-pwa

Pure Http
✨ The simple web framework for Node.js with zero dependencies.
Stars: ✭ 139 (+892.86%)
Mutual labels:  expressjs, http-server
pppr
pppr is a prerender service
Stars: ✭ 18 (+28.57%)
Mutual labels:  expressjs, puppeteer
node-slack-events-api
Slack Events API for Node
Stars: ✭ 93 (+564.29%)
Mutual labels:  expressjs, http-server
Linkedin Profile Scraper
🕵️‍♂️ LinkedIn profile scraper returning structured profile data in JSON. Works in 2020.
Stars: ✭ 171 (+1121.43%)
Mutual labels:  expressjs, puppeteer
mugshot
Framework independent visual testing library
Stars: ✭ 126 (+800%)
Mutual labels:  puppeteer
WebServer
High-performance multi-threaded tcp network server in c++11
Stars: ✭ 58 (+314.29%)
Mutual labels:  http-server
heart
A high performance Lua web server with a simple, powerful API
Stars: ✭ 78 (+457.14%)
Mutual labels:  http-server
wine
A lightweight and flexible framework to help build elegant web API
Stars: ✭ 39 (+178.57%)
Mutual labels:  http-server
fancy
High performance web server
Stars: ✭ 20 (+42.86%)
Mutual labels:  http-server
trafficator
Traffic generator for local analytics testing
Stars: ✭ 27 (+92.86%)
Mutual labels:  puppeteer
phorklift
Phorklift is an HTTP server and proxy daemon, with clear, powerful and dynamic configuration.
Stars: ✭ 43 (+207.14%)
Mutual labels:  http-server
Jarvis
APL-based web service framework supporting JSON or REST
Stars: ✭ 17 (+21.43%)
Mutual labels:  http-server
quiki
a file-based web engine and server featuring a productive source language, markdown, image generation, categories, templates, and revision tracking
Stars: ✭ 20 (+42.86%)
Mutual labels:  http-server
barclayscrape
A small app to programmatically mainpulate Barclays online banking
Stars: ✭ 57 (+307.14%)
Mutual labels:  puppeteer
squilu
A scripting language that accepts a subset of javascript and C/C++
Stars: ✭ 69 (+392.86%)
Mutual labels:  http-server
HttpServerLite
TCP-based simple HTTP and HTTPS server, written in C#.
Stars: ✭ 44 (+214.29%)
Mutual labels:  http-server
abeamer
frame-by-frame Web Animation framework
Stars: ✭ 49 (+250%)
Mutual labels:  puppeteer
puppeteer-loadtest
load test puppeteer (Headless Chrome API) script using node
Stars: ✭ 107 (+664.29%)
Mutual labels:  puppeteer
webgif
Easily generate animated GIFs from websites
Stars: ✭ 98 (+600%)
Mutual labels:  puppeteer
mirror-http-server
A dummy HTTP server that responds whatever you told it to
Stars: ✭ 35 (+150%)
Mutual labels:  http-server

http-server-pwa aka pwa-server

npm Build Status Build status codecov

http-server alike but for serving and rendering PWA: pwa-server

What

This is a different version (btw inspired by) of the insta-ready http-server, but with some key features to render Progressive Web Apps (or also SPA) correctly for bots like googlebot or Facebook crawlers, so your application can be crawled with its content already loaded. This should avoid the killing problem of the SEO for PWAs.

The server will render as normal, static ExpressJS server for your normal users.

Worth noting is that the server supports the history-fallback behavior. You maybe can avoid that # (hash) for your PWA navigation ✌️.

Features

The server is not "dependecies-free" like the original http-server and instead is powered by ExpressJS under the hood and Puppeter for render the pages to bots.

  • pupperender - Puppeter middleware to render correctly the PWA content for the crawlers.
  • express-history-api-fallback - to fallback correctly to the index.html.
  • express-http-to-https - automatically redirect http requests to https.
  • devcert - Create development certificate on the fly for local https. NOTE: you could be prompted to insert your password before starting the server. This is necessary of using OpenSSL. More info on devcert repository.

Production usage

The server will not create any SSL certificate on the fly when you set process.env.NODE_ENV = production even if --ssl flag is passed down. You have two alternatives here:

  • use a reverse proxy like CloudFlare and get free certification for your domain - easy peasy
  • use a custom reverse proxy like Nginx and load your certification from there

I currently don't want to support a custom certificate load. PR are always welcome.

Deploy on Heroku

In order to make the server work as expected on Heroku services (even on free tier) you must add the puppeteer-heroku-buildpack.

Since recent changes on the platform it is strongly suggested to add it from source rather than the buildpack's catalogs.

$ heroku buildpacks:set https://github.com/jontewks/puppeteer-heroku-buildpack.git

Usage

You can use it programmatically or as a CLI tool (global or local).

Install

$ yarn add http-server-pwa

Usage

const httpServerPwa = require('http-server-pwa');

const server = await httpServerPwa('./dist', {p: 3000});
//=> Server started -> ./dist localhost:3000

API

httpServerPwa(path, [options])

path

Type: string

Path to serve.

options

Name CLI flag Type Default Description
port p number 8080 Port to use for running the server.
host h string localhost Host to use for running the server.
fallback f string index.html Fallback HTML file name.
https s boolean false Enable HTTPS redirect on localhost.
ssl boolean false Enable devcert auto-generation of SSL certification for development.
cache c boolean false Enable cache for Puppeteer rendering
cacheTTL number 3600 (s) Seconds until cached content is disregarded and puppeterized again. Only considered when cache is true.
debug d boolean false If or not show some logs.
gzip g boolean false Enable serving of gzipped files if available
brotli b boolean false Enable serving of brotli compressed files if available

Note: If the gzip and brotli option are both toggled, brotli compressed files will get precedence over gzipped files.

CLI

$ yarn add --global http-server-pwa
$ http-server-pwa --help # or pwa-server --help

  Usage
	  $ http-server-pwa [path] [options]

	Options
		-p --port       Port to use [Default: 8080]
		-h --host       Host to use [Default: localhost | Windows: 127.0.0.1]
		-f --fallback   Fallback HTML file name [Default: index.html]
		-s --https      Enable HTTPS redirect on localhost [Default: false]
		--ssl           Auto-generation SSL certificate during development [Default: false]
		-c --cache      Enable cache for Puppeteer rendering [Default: false]
		--cacheTTL      Seconds until cached content is disregarded and puppeterized again [Default: 3600 (s)].
		-d --debug      Be more verbose [Default: false]
		-g --gzip	Enable serving of gzipped files if available [Default: false]
		-b --brotli	Enable serving of brotli compressed files if available [Default: false]
		-h --help       Show this message

	Examples
	  $ http-server-pwa
	  Server started -> ./ localhost:8080
	  $ http-server-pwa dist -p 3000
	  Server started -> ./dist localhost:3000

License

MIT © LasaleFamine

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].