Socket
Socket
Sign inDemoInstall

fastboot-express-middleware

Package Overview
Dependencies
Maintainers
6
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastboot-express-middleware - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

4

package.json
{
"name": "fastboot-express-middleware",
"version": "1.1.0",
"version": "1.1.1",
"description": "An Express middleware for rendering Ember apps with FastBoot",

@@ -41,5 +41,5 @@ "main": "src/index.js",

"chalk": "^2.0.1",
"fastboot": "^1.1.0",
"fastboot": "^1.1.2",
"request": "^2.81.0"
}
}

@@ -92,2 +92,18 @@ # FastBoot Express Middleware

## Response chunking
By default, the middleware writes the complete response at once but response
chunking (aka HTTP Streaming) is available via a config switch:
```js
app.get('/*', fastbootMiddleware({
distPath: '/path/to/dist',
chunkedResponse: true
}));
```
Enabling response chunking will result in the response being delivered in
multiple chunks (one for the head, one for the body and one for each shoebox)
which helps getting the HTML to clients faster.
[ember-cli-fastboot]: https://github.com/ember-fastboot/ember-cli-fastboot

@@ -94,0 +110,0 @@

@@ -35,24 +35,33 @@ 'use strict';

function success(result) {
result.html()
.then(html => {
let headers = result.headers;
let statusMessage = result.error ? 'NOT OK ' : 'OK ';
let responseBody = opts.chunkedResponse ? result.chunks() : result.html();
for (var pair of headers.entries()) {
res.set(pair[0], pair[1]);
}
responseBody.then(body => {
let headers = result.headers;
let statusMessage = result.error ? 'NOT OK ' : 'OK ';
for (var pair of headers.entries()) {
res.set(pair[0], pair[1]);
}
if (result.error) {
log("RESILIENT MODE CAUGHT:", result.error.stack);
next(result.error);
}
log(result.statusCode, statusMessage + path);
res.status(result.statusCode);
if (result.error) {
log("RESILIENT MODE CAUGHT:", result.error.stack);
next(result.error);
}
log(result.statusCode, statusMessage + path);
res.status(result.statusCode);
res.send(html);
})
.catch(error => {
res.status(500);
next(error);
});
if (typeof body === 'string') {
res.send(body);
} else if (result.error) {
res.send(body[0]);
} else {
body.forEach(chunk => res.write(chunk));
res.end();
}
})
.catch(error => {
res.status(500);
next(error);
});
}

@@ -59,0 +68,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc