ember-fastboot / fastboot-express-middleware

An Express middleware for rendering Ember apps with FastBoot
17 stars 43 forks source link

Returning HTML on Fastboot success prevents option of manipulating HTML afterFastboot #30

Open lukeclewlow opened 7 years ago

lukeclewlow commented 7 years ago

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.

kratiahuja commented 7 years ago

I believe this would break existing apps. While I like the idea, if you want to cache your base page, wouldn't something like Ember-static-boot be more fitting?

I am open to calling next() as an opt-in rather than the default.

lukeclewlow commented 7 years ago

Its slightly more complicated than I made out, and we don't want to serve a static site. Just cache the result of the fastboot rendered page so fastboot doesn't need to render it if nothing will have changed to make that necessary. The fastboot part is still very much a necessity for us.

Opting in would be great as I can see that it could be a breaking change otherwise.

kratiahuja commented 7 years ago

Would you mind opening a PR with this being an opt-in functionality? And from there we can see how we want to land this.