Git Product home page Git Product logo

fastboot-express-middleware's People

Contributors

bekzod avatar bobisjan avatar danmcclain avatar greenkeeper[bot] avatar habdelra avatar izelnakri avatar kitsunde avatar kratiahuja avatar locks avatar marcoow avatar pwfisher avatar rwjblue avatar sdhull avatar suchitadoshi1987 avatar tomdale avatar tuanluu-agilityio avatar xg-wang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastboot-express-middleware's Issues

HTTP 2.0 Server Push?

I'm not sure what the status of HTTP 2.0 Server Push support in express.js is actually but if it supports it shouldn't we be able to take advantage of it by pushing the assets to the client along with the prerendered HTML?

Maybe there's an obvious reason why we don't do that yet that I'm just not seeing - if so, please go ahead and close this and sorry for the noise.

An in-range update of express is breaking the build 🚨

The devDependency express was updated from 4.16.4 to 4.17.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

express is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for 4.17.0
Commits

The new version differs by 53 commits.

There are 53 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Unable to Pass Data to Fastboot through Middleware

I was working on a feature that used an npm package to get the IP address of a client conncting to the Fastboot server, which was configured as a middleware in fastboot-server.js, which initializes Fastboot using this middleware. However, it appears that there is no way to pass data to Fastboot through fastboot-express-middleware, which makes it very challenging to extend Fastboot using other middlewares.

Let me know if you need more information about my use case, but overall I think it would be important to maintain modularity by allowing information to be passed into Fastboot through this middleware.

Release with FastBoot 2+ support

Hi πŸ‘‹,

the fastboot 2+ dependency is already included it the package.json πŸŽ‰.

Would it make sense to release a new version, so ember-cli-fastboot and fastboot-app-server can be updated too?

Test that tests resilient mode without custom error handler incorrect

Calling all knowledgeable Express.js folks!

The test case in this repo that tests resilient mode without a custom error handler should fail (eg, it does IRL when using resilient mode without a custom error handler), but for some reason it passes.

My impression from reading the docs is that the default Express error handler will render the built-in error page when it gets called, which will in turn subvert the resilient behavior.

So you actually must define an error handler like

app.use(function (err, req, res, next) {
  console.error(err.stack)
  next();
})

To essentially ignore the error and allow resilient mode to continue.

But the tests don't reflect that. Are they somehow turning off the default error handler in express?

Can't get distPath when set value to resilient mode

Currently when we set value resilient: true, fastboot-express-middleware show undefined on distPath with code:

app.get('/*', fastbootMiddleware('/path/to/dist', {
  resilient: true
}));

Code above show options paramter on constructor in path file: node_modules/fastboot/src/index.js:

{distPath: undefined, resilient: true}

I have update it with code:

app.get('/*', fastbootMiddleware({
  distPath: '/path/to/dist',
  resilient: true
}));

Code above show options paramter on constructor in path file: node_modules/fastboot/src/index.js:

{distPath:  '/path/to/dist', resilient: true}

It work fine to me.

Please help check it again.

Thanks,

Duplicate response headers overwritten, not appended

FastBoot provides us with an API to append headers to the response. If you set the same header more than once, FastBoot will store the values in an array. However, the Express middleware then loops through the flattened array of header entries and sets them using res.set(), which overwrites any duplicate headers with the last value.

let headers = result.headers;
let statusMessage = result.error ? 'NOT OK ' : 'OK ';
for (var pair of headers.entries()) {
res.set(pair[0], pair[1]);
}

Example

If you wanted to return several cookies, you might try the following:

let responseHeaders = this.get('fastboot.response.headers');
responseHeaders.append('set-cookie', 'first_cookie=...; path=/');
responseHeaders.append('set-cookie', 'second_cookie=...; path=/');

The first cookie gets overwritten by the second in the response.

In the wild

Both ember-simple-auth and ember-cookies seem to expect the cookies to be appended, not overwritten with the last value.

In ember-cookies: https://github.com/simplabs/ember-cookies/blob/0a0fb0e4d85b70041258829c5e7e2e4f1359ca7b/addon/services/cookies.js#L94-L105

  _writeFastBootCookie(name, value, options = {}) {
    let responseHeaders = this.get('_fastBoot.response.headers');
    let serializedCookie = this._serializeCookie(...arguments);


    if (!isEmpty(options.maxAge)) {
      options.maxAge *= 1000;
    }


    this._cacheFastBootCookie(...arguments);


    responseHeaders.append('set-cookie', serializedCookie);
  },

This innocuous code then produces subtle bugs in code like this in ember-simple-auth: https://github.com/simplabs/ember-simple-auth/blob/master/addon/session-stores/cookie.js#L246

this.get('_cookies').write(this.get('cookieName'), value, cookieOptions);
if (!isEmpty(expiration)) {
  let expirationCookieName = `${this.get('cookieName')}-expiration_time`;
  let cachedExpirationTime = this.get('_cookies').read(expirationCookieName);
  this.get('_cookies').write(expirationCookieName, this.get('cookieExpirationTime') || cachedExpirationTime, cookieOptions);
}

ember-simple-auth depends on the cookie store in FastBoot, so if you set an expiration date on your auth cookies, this expiration cookie will overwrite your auth cookie.

I assume this is not really the intended behaviour, especially for the append method of the fetch header API. I know Express previously provided all sorts of patches, including automatically appending duplicate header values (https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x#ressetheaderset-cookie-val).

The best solution I can come up with would be to handle the cookies with res.cookie here and let users pass in cookies via the FastBoot service. That's gonna require changes in 3 repos at least, so not sure how people feel about that.

We can filter out the cookie headers and set them all at once (which correctly sets multiple set-cookie headers), but we don't want to send more than one cookie with the same name. ember-simple-auth in particular will write the auth cookie 3-4 times for some reason. So, we'd have to parse the serialized cookies to check for duplicates – doesn't sound like a great idea.

An in-range update of fastboot is breaking the build 🚨

The dependency fastboot was updated from 2.0.2 to 2.0.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

fastboot is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Unable to fetch assets after Ember 2.7 upgrade

After upgrading to Ember 2.7 (which included deprecation of baseURL) and starting an Ember app using Fastboot, the app tries to retrieve assets based on the rootURL specified, e.g.

  • rootURL/assets/vendor.css
  • rootURL/assets/appName.js

However, Fastboot is still serving these assets at

  • assets/vendor.css
  • assets/appName.js

Returning HTML on Fastboot success prevents option of manipulating HTML afterFastboot

My use case is that I want to cache the HTML that is generated from Fastboot. I use fastboot-express-middleware as middleware with fastboot-app-server. This has an afterFastboot hook, which is only accessible on an error because index.js line 51 res.send(html) just returns the HTML rather than calling next().

What I currently do is replace that line with next() and pass through the html on the response object.

Is this something that might be good to change, and how would it affect users not using fastboot-app-server?

Happy to make a pull request if you did think this was a valid change.

An in-range update of request-promise is breaking the build 🚨

The devDependency request-promise was updated from 4.2.2 to 4.2.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

request-promise is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 17 commits.

  • d831905 Version 4.2.3 (now really)
  • 37e8773 fix: updated indirect lodash dependency to fix security vulnerability
  • 229225e Version 4.2.3
  • 4f27097 chore: fix ci build for node v8+
  • c535eb6 Merge pull request #299 from aomdoa/fixToughCookieDep
  • 488947b Merge branch 'master' into fixToughCookieDep
  • 131abd7 fix: breaking change in tough-cookie v3
  • b454ddc chore: added node 8 and 10 to ci build
  • 6d11ddc fix: typo
  • 3a136ea Merge pull request #303 from lexjacobs/patch-1
  • 5e32191 docs: mention of wrapped request errors
  • 2ac4f3e Update rp.js
  • 1457338 Workaround on the cookie processing test.
  • 062d5f8 Limit the tough-cookie to 2.5 as 3.x removes node 0.10 support
  • 18c838a docs: cheat sheet for POST like HTML forms do

There are 17 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.