Last active
June 17, 2019 22:53
-
-
Save 0xadada/04bddc6c5d459796a3b8f706417f78b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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