simplabs/fastboot

Name: fastboot

Owner: simplabs

Description: FastBoot is a library for rendering Ember.js applications in Node.js.

Created: 2016-05-11 15:03:42.0

Updated: 2016-05-11 15:03:43.0

Pushed: 2017-11-29 20:22:33.0

Homepage:

Size: 2671

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

FastBoot

Greenkeeper badge npm version Build Status Ember Version

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 v4 or later.

Usage
t FastBoot = require('fastboot');

app = new FastBoot({
stPath: 'path/to/dist',
 optional boolean flag when set to true does not reject the promise if there are rendering errors (defaults to false)
silient: <boolean>,
ndbox: 'path/to/sandbox/class', // optional sandbox class (defaults to vm-sandbox)
ndboxGlobals: {...} // optional map of key value pairs to expose in the sandbox


visit('/photos', options)
hen(result => result.html())
hen(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.

Additional configuration

app.visit takes a second parameter as options above which a map and allows to define additional optional per request configuration:

Build Your App

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:

ber 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. Upload this file to your FastBoot server.

Command Line

You can start a simple HTTP server that responds to incoming requests by rendering your Ember.js application using the FastBoot App Server

Debugging

Run fastboot with the DEBUG environment variable set to fastboot:* for detailed logging.

The Shoebox

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:



ipt type="fastboot/shoebox" id="shoebox-main-store">
ta":[{"attributes":{"name":"AEC Professionals"},"id":106,"type":"audience"},
tributes":{"name":"Components"},"id":111,"type":"audience"},
tributes":{"name":"Emerging Professionals"},"id":116,"type":"audience"},
tributes":{"name":"Independent Voters"},"id":2801,"type":"audience"},
tributes":{"name":"Members"},"id":121,"type":"audience"},
tributes":{"name":"Partners"},"id":126,"type":"audience"},
tributes":{"name":"Prospective Members"},"id":131,"type":"audience"},
tributes":{"name":"Public"},"id":136,"type":"audience"},
tributes":{"name":"Staff"},"id":141,"type":"audience"},
tributes":{"name":"Students"},"id":146,"type":"audience"}]}
ript>



This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.