Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastboot-express-middleware

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastboot-express-middleware

An Express middleware for rendering Ember apps with FastBoot

  • 1.0.0-beta.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
increased by6.83%
Maintainers
2
Weekly downloads
 
Created
Source

FastBoot Express Middleware

Build Status

This middleware is a small wrapper around the fastboot package, which renders Ember.js apps in Node.js.

By adding this middleware to your Express app, you can serve HTML from a rendered Ember.js app to clients that don't support JavaScript, such as curl, search crawlers, or users with JavaScript disabled.

Note that this is just an Express middleware and there is more needed to serve apps in a production environment. If you want to server-side rendered Ember applications without doing a lot of work, you are recommended to consider the FastBoot App Server, which manages many of the hard parts for you.

That said, this middleware is designed to be easy to integrate for those who already have existing Express stacks, or who want maximum flexibility in how requests are handled.

Usage

const express = require('express');
const fastbootMiddleware = require('fastboot-express-middleware');

let app = express();

app.get('/*', fastbootMiddleware('/path/to/dist'));

app.listen(3000, function () {
  console.log('FastBoot app listening on port 3000!');
});

Building Your Ember App

Before you can use your app with FastBoot, you must first install the ember-cli-fastboot addon and build your app by running ember build. The build process will compile your app into a version that is compatible with both Node.js and the browser and put it in the dist directory. This dist directory is the path you should provide to the middleware to specify which Ember app to load and render.

Resilient Mode

By default, errors during render will cause the middleware to send an HTTP 500 status code as the response. In order to swallow errors and return a 200 OK with an empty HTML page, set the resilient flag to true:

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

Custom FastBoot Instance

For more control over the FastBoot instance that is created to render the Ember app, you can pass a custom instance that the middleware will use instead of creating its own:

let fastboot = new FastBoot({
  distPath: 'path/to/dist'
});

let middleware = fastbootMiddleware({
  fastboot: fastboot
});

app.get('/*', middleware);

// ...later
fastboot.reload();

Tests

npm test

Keywords

FAQs

Package last updated on 17 May 2016

Did you know?

Socket

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.

Install

Related posts

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