Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
FastBoot is a library for rendering Ember.js applications in Node.js.
For more information about FastBoot, see www.ember-fastboot.com, the Ember CLI addon that's a prerequisite for developing FastBoot apps.
To serve server-rendered versions of your Ember app over HTTP, see the FastBoot App Server.
FastBoot requires Node.js v6 or later.
const FastBoot = require('fastboot');
let app = new FastBoot({
distPath: 'path/to/dist',
// optional boolean flag when set to true does not reject the promise if there are rendering errors (defaults to false)
resilient: <boolean>,
// optional function used to generate the set of global properties available within the sandbox, receives default globals
// and is expected to return an object (the default implementation returns the passed in defaults)
buildSandboxGlobals(defaultGlobals) {
return Object.assign({}, defaultGlobals, {
// additional global properties to define within the sandbox
});
},
});
app.visit('/photos', options)
.then(result => result.html())
.then(html => res.send(html));
In order to get a dist
directory, you will first need to build your
Ember application, which packages it up for using in both the browser
and in Node.js.
FastBoot
object will be available to the sandboxed environment. This object has the following form:
FastBoot.require // provides a mechanism to load additional modules. Note: these modules are only those included in the module whitelist
FastBoot.config // a function which takes a key, and returns the corresponding fastboot config value
FastBoot.distPath // readOnly accessor that provides the dist path for the current fastboot sandbox
app.visit
takes a second parameter as options
above which a map and allows to define additional optional per request
configuration:
resilient
: whether to reject the returned promise if there is an error during rendering. If not defined, defaults to the app's resilient setting.html
: the HTML document to insert the rendered app into. Uses the built app's index.html by default.metadata
: per request meta data that is exposed in the app via the fastboot service.shouldRender
: boolean to indicate whether the app should do rendering or not. If set to false, it puts the app in routing-only. Defaults to true.disableShoebox
: boolean to indicate whether we should send the API data in the shoebox. If set to false, it will not send the API data used for rendering the app on server side in the index.html. Defaults to false.destroyAppInstanceInMs
: whether to destroy the instance in the given number of ms. This is a failure mechanism to not wedge the Node processbuildSandboxPerVisit
: whether to create a new sandbox context per-visit (slows down each visit, but guarantees no prototype leakages can occur), or reuse the existing sandbox (faster per-request, but each request shares the same set of prototypes). Defaults to false.To get your Ember.js application ready to both run in your user's browsers and run inside the FastBoot environment, run the Ember CLI build command:
$ ember build --environment production
(You will need to have already set up the ember-cli-fastboot addon. For more information, see the FastBoot quickstart.)
Once this is done, you will have a dist
directory that contains the
multi-environment build of your app.
Run the command to install run time node modules:
$ cd dist/
$ npm install
Upload the dist/
folder including node_modules
to your FastBoot server.
You can start a simple HTTP server that responds to incoming requests by rendering your Ember.js application using the FastBoot App Server
Run fastboot
with the DEBUG
environment variable set to fastboot:*
for detailed logging.
You can pass application state from the FastBoot rendered application to the browser rendered application using a feature called the "Shoebox". This allows you to leverage server API calls made by the FastBoot rendered application on the browser rendered application. Thus preventing you from duplicating work that the FastBoot application is performing. This should result in a performance benefit for your browser application, as it does not need to issue server API calls whose results are available from the Shoebox.
The contents of the Shoebox are written to the HTML as strings within
<script>
tags by the server rendered application, which are then consumed
by the browser rendered application.
This looks like:
.
.
<script type="fastboot/shoebox" id="shoebox-main-store">
{"data":[{"attributes":{"name":"AEC Professionals"},"id":106,"type":"audience"},
{"attributes":{"name":"Components"},"id":111,"type":"audience"},
{"attributes":{"name":"Emerging Professionals"},"id":116,"type":"audience"},
{"attributes":{"name":"Independent Voters"},"id":2801,"type":"audience"},
{"attributes":{"name":"Members"},"id":121,"type":"audience"},
{"attributes":{"name":"Partners"},"id":126,"type":"audience"},
{"attributes":{"name":"Prospective Members"},"id":131,"type":"audience"},
{"attributes":{"name":"Public"},"id":136,"type":"audience"},
{"attributes":{"name":"Staff"},"id":141,"type":"audience"},
{"attributes":{"name":"Students"},"id":146,"type":"audience"}]}
</script>
.
.
v3.0.1 (2020-03-12)
FAQs
Library for rendering Ember apps in node.js
The npm package fastboot receives a total of 13,310 weekly downloads. As such, fastboot popularity was classified as popular.
We found that fastboot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.