Middleware for express based apps which serves static files via sirv using h2-auto-push
npm install sirv-auto-pushbash
npm i -S sirv-auto-push
`
$3
`bash
yarn add sirv-auto-push
`
Usage
`js
const express = require('express');
const sirvAp = require('sirv-auto-push');
const app = express();
app.use(sirvAp("static", { dev: IS_DEV }));
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.listen(3000, function () {
console.log('Server listening on port 3000');
});
`
API
$3
Returns: Function
The returned function is a middleware in the standard Express-like signature: (req, res, next), where req is the http.IncomingMessage, res is the http.ServerResponse, and next (in this case) is the function to call if no file was found for the given path.
#### dir
Type: String
Default: .
The directory from which to read and serve assets. It is resolved to an absolute path — you must provide an absolute path yourself if process.cwd() is not the correct assumption.
#### opts.prefix
Type: String
Default: /
Record file for auto pushing only when the path starts with prefix`.