Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function(distPath, opts={}) {
const OPTIONS = typeof distPath === 'string' ? Object.assign({
distPath: distPath
}, opts) : distPath;
const fastboot = OPTIONS.fastboot || new FastBoot({
distPath: OPTIONS.distPath,
resilient: OPTIONS.resilient === false ? false : true
});
return function(req, response, next) {
let result;
fastboot.visit(req.path, { request: req, response: response }).then((res) => {
result = res;
return OPTIONS.chunkedResponse ? result.chunks() : result.html();
}, (error) => console.log('error is', error)).then((body) => {
let headers = result.headers;
let statusMessage = result.error ? 'NOT OK ' : 'OK ';
for (var pair of headers.entries()) {
response.set(pair[0], pair[1]);