Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xadada/04bddc6c5d459796a3b8f706417f78b0 to your computer and use it in GitHub Desktop.
Save 0xadada/04bddc6c5d459796a3b8f706417f78b0 to your computer and use it in GitHub Desktop.
// LOL this is not production code, but "inspired" by production code
const FastBoot = require('fastboot');
const FastBootAppServer = require('fastboot-app-server');
const server = new FastBootAppServer({
gzip: true, // enable gzip compression
beforeMiddleware(app) {
app.use(async (request, response, next) => {
if (request.path === '/render') {
const app = new FastBoot({ distPath: 'dist' });
const result = await app.visit('/render', { request, response }); // <== our Ember.js rendering route
const { body } = result.domContents();
response.end(body);
} else {
next();
}
});
},
});
process.on('uncaughtException', function(error) {
logger.error(`exiting, uncaught exception: ${error}`);
// fail early, fail hard
// here be an unknown error, gracefully shut down the process, fastboot will restart it
process.exit(1);
});
server.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment