Skip to content

Instantly share code, notes, and snippets.

@tylr
Last active January 19, 2016 00:15
Show Gist options
  • Save tylr/6b621d50ac4a706238c0 to your computer and use it in GitHub Desktop.
Save tylr/6b621d50ac4a706238c0 to your computer and use it in GitHub Desktop.
Running Ember FastBoot in AWS Lambda
var path = require('path');
var FastBootServer = require('./lib/models/server');
var outputPath = 'fastboot-dist';
var appName = 'dummy';
var server = new FastBootServer({
appFile: findAppFile(outputPath, appName),
vendorFile: findVendorFile(outputPath),
htmlFile: findHTMLFile(outputPath)
});
exports.render = function(event, context) {
server.render(event.path)
.then(context.succeed)
.catch(context.fail);
}
function findAppFile(outputPath, appName) {
return findFile("app", path.join(outputPath, "assets", appName + "*.js"));
}
function findVendorFile(outputPath) {
return findFile("vendor", path.join(outputPath, "assets", "vendor*.js"));
}
function findHTMLFile(outputPath) {
return findFile('html', path.join(outputPath, 'index*.html'));
}
function findFile(name, globPath) {
var glob = require('glob');
var files = glob.sync(globPath);
return files[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment