Socket
Socket
Sign inDemoInstall

ember-fastboot-server

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-fastboot-server - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

.travis.yml

7

lib/ember-app.js

@@ -20,2 +20,3 @@ var fs = require('fs');

var moduleWhitelist = options.moduleWhitelist;
this._hostWhitelist = options.hostWhitelist;

@@ -75,3 +76,3 @@ debug("app created; app=%s; vendor=%s", appFilePath, vendorFilePath);

return this.buildApp()
.then(registerFastBootInfo(req, res))
.then(registerFastBootInfo(req, res, this._hostWhitelist))
.then(function(instance) {

@@ -105,5 +106,5 @@ return instance.boot(bootOptions);

*/
function registerFastBootInfo(req, res) {
function registerFastBootInfo(req, res, hostWhitelist) {
return function(instance) {
var info = new FastBootInfo(req, res);
var info = new FastBootInfo(req, res, hostWhitelist);
info.register(instance);

@@ -110,0 +111,0 @@

@@ -8,3 +8,3 @@ var cookie = require('cookie');

*/
function FastBootInfo(request, response) {
function FastBootInfo(request, response, hostWhitelist) {
this.request = request;

@@ -15,2 +15,3 @@ this.response = response;

this.headers = request.headers;
this.hostWhitelist = hostWhitelist;
}

@@ -35,2 +36,28 @@

FastBootInfo.prototype.host = function() {
if (!this.hostWhitelist) {
throw new Error('You must provide a hostWhitelist to retrieve the host');
}
var host = this.request.headers.host;
var matchFound = this.hostWhitelist.reduce(function(previous, currentEntry) {
if (currentEntry[0] === '/' &&
currentEntry.slice(-1) === '/') {
// RegExp as string
var regexp = new RegExp(currentEntry.slice(1, -1));
return previous || regexp.test(host);
} else {
return previous || currentEntry === host;
}
}, false);
if (!matchFound) {
throw new Error('The host header did not match a hostWhitelist entry');
}
return this.request.protocol + '://' + host;
};
/*

@@ -37,0 +64,0 @@ * Registers this FastBootInfo instance in the registry of an Ember

@@ -1,10 +0,25 @@

var chalk = require('chalk');
var fs = require('fs');
var path = require('path');
var chalk = require('chalk');
var fs = require('fs');
var path = require('path');
var util = require('util');
var EmberApp = require('./ember-app');
var debug = require('debug')('ember-cli-fastboot:server');
var debug = require('debug')('ember-cli-fastboot:server');
function FastBootServer(options) {
options = options || {};
var distPath = options.distPath;
if (!distPath) {
throw new Error('You must instantiate FastBootServer with a distPath ' +
'option that contains a path to a fastboot-dist directory ' +
'produced by running ember fastboot:build in your Ember app:' +
'\n\n' +
'new FastBootServer({\n' +
' distPath: \'path/to/fastboot-dist\'\n' +
'});');
}
var config = readPackageJSON(distPath);
// Stubs out the `ui` object for printing to the terminal used

@@ -22,3 +37,4 @@ // by Ember CLI addons.

vendorFile: config.vendorFile,
moduleWhitelist: config.moduleWhitelist
moduleWhitelist: config.moduleWhitelist,
hostWhitelist: config.hostWhitelist
});

@@ -107,20 +123,29 @@

var pkgPath = path.join(distPath, 'package.json');
var file;
try {
var file = fs.readFileSync(pkgPath);
file = fs.readFileSync(pkgPath);
} catch (e) {
throw new Error(util.format("Couldn't find %s. You may need to update your version of ember-cli-fastboot.", pkgPath));
}
var pkg = JSON.parse(file);
var manifest = pkg.fastboot.manifest;
var manifest;
var pkg;
return {
appFile: path.join(distPath, manifest.appFile),
vendorFile: path.join(distPath, manifest.vendorFile),
htmlFile: path.join(distPath, manifest.htmlFile),
moduleWhitelist: pkg.fastboot.moduleWhitelist
};
try {
pkg = JSON.parse(file);
manifest = pkg.fastboot.manifest;
} catch (e) {
console.log("Couldn't find %s. You may need to update your version of ember-cli-fastboot.", pkgPath);
throw new Error(util.format("%s was malformed or did not contain a manifest. Ensure that you have a compatible version of ember-cli-fastboot.", pkgPath));
}
return {
appFile: path.join(distPath, manifest.appFile),
vendorFile: path.join(distPath, manifest.vendorFile),
htmlFile: path.join(distPath, manifest.htmlFile),
moduleWhitelist: pkg.fastboot.moduleWhitelist,
hostWhitelist: pkg.fastboot.hostWhitelist
};
}
module.exports = FastBootServer;
{
"name": "ember-fastboot-server",
"version": "0.5.1",
"version": "0.5.2",
"description": "Production server for running Ember applications using FastBoot",
"main": "./lib/server",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},

@@ -34,7 +34,13 @@ "repository": {

"minimist": "^1.2.0",
"najax": "^0.3.2",
"najax": "^0.4.0",
"rsvp": "^3.0.16",
"simple-dom": "^0.2.7",
"source-map-support": "^0.4.0"
},
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^5.2.0",
"mocha": "^2.4.5",
"request-promise": "^2.0.1"
}
}
# Ember FastBoot Server
[![Build Status](https://travis-ci.org/ember-fastboot/ember-fastboot-server.svg?branch=master)](https://travis-ci.org/ember-fastboot/ember-fastboot-server)
The Ember FastBoot Server is used to render Ember.js applications on the

@@ -4,0 +6,0 @@ server and deliver them to clients over HTTP. This server is meant to be

Sorry, the diff of this file is not supported yet

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