steal-push
steal-push is server middleware for HTTP2 push. Using steal-tools you can create a bundle manifest that species which modules need to be loaded for each bundle. steal-push uses this manifest file to push files when a given route is used.
steal-push also works with HTTP1 servers, adding a Link header which tells the browser to begin fetching/parsing the assets.
Install
npm install steal-push --save
Setup
Before using steal-push you must generate a bundle manifest from steal-tools like so:
stealTools;
Usage
steal-push can be used in plain Node web servers, or in express apps.
Node
const http2 = ;const stealPush = ; const pushMain = ;const pushOrders = ; { ifrequrl === "/" ; res; else ; res; } spdy;
Express
const express = ;const fs = ;const stealPush = ;const spdy = ; const app = ;const server = spdy; app; app; server;
StealPush constructor
The StealPush
constructor can be used to configure things such as the server root, and the location of the manifest file. Typical usage looks like:
const StealPush = StealPush; const stealPush = manifest: "dist/bundles.json" root: __dirname + "/assets" serverRoot: "/app"; app;
StealPush#for
The for()
method on the StealPush object is used to create a function that takes a request and response object.
License
MIT