Last active
January 19, 2016 00:15
-
-
Save tylr/6b621d50ac4a706238c0 to your computer and use it in GitHub Desktop.
Running Ember FastBoot in AWS Lambda
This file contains hidden or 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
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