Skip to content

Commit

Permalink
Merge pull request #124 from zonkyio/update-fastboot-3
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Oct 26, 2020
2 parents 32e5418 + 82362c9 commit 4e80446
Show file tree
Hide file tree
Showing 7 changed files with 473 additions and 66 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -43,7 +43,9 @@ let server = new FastBootAppServer({
gzip: true, // Optional - Enables gzip compression.
host: '0.0.0.0', // Optional - Sets the host the server listens on.
port: 4000, // Optional - Sets the port the server listens on (defaults to the PORT env var or 3000).
sandboxGlobals: { GLOBAL_VALUE: MY_GLOBAL }, // Optional - Make values available to the Ember app running in the FastBoot server, e.g. "MY_GLOBAL" will be available as "GLOBAL_VALUE"
buildSandboxGlobals(defaultGlobals) { // Optional - Make values available to the Ember app running in the FastBoot server, e.g. "MY_GLOBAL" will be available as "GLOBAL_VALUE"
return Object.assign({}, defaultGlobals, { GLOBAL_VALUE: MY_GLOBAL });
},
chunkedResponse: true // Optional - Opt-in to chunked transfer encoding, transferring the head, body and potential shoeboxes in separate chunks. Chunked transfer encoding should have a positive effect in particular when the app transfers a lot of data in the shoebox.
});

Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -30,8 +30,8 @@
"chalk": "^2.0.1",
"compression": "^1.6.2",
"express": "^4.13.3",
"fastboot": "^2.0.0",
"fastboot-express-middleware": "^2.0.0"
"fastboot": "^3.1.1",
"fastboot-express-middleware": "^3.0.0"
},
"devDependencies": {
"chai": "^4.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/fastboot-app-server.js
Expand Up @@ -23,7 +23,7 @@ class FastBootAppServer {
this.httpServer = options.httpServer;
this.beforeMiddleware = options.beforeMiddleware;
this.afterMiddleware = options.afterMiddleware;
this.sandboxGlobals = options.sandboxGlobals;
this.buildSandboxGlobals = options.buildSandboxGlobals;
this.chunkedResponse = options.chunkedResponse;

if (!this.ui) {
Expand All @@ -46,7 +46,7 @@ class FastBootAppServer {
httpServer: this.httpServer,
beforeMiddleware: this.beforeMiddleware,
afterMiddleware: this.afterMiddleware,
sandboxGlobals: this.sandboxGlobals,
buildSandboxGlobals: this.buildSandboxGlobals,
chunkedResponse: this.chunkedResponse,
});

Expand Down
6 changes: 3 additions & 3 deletions src/worker.js
Expand Up @@ -17,7 +17,7 @@ class Worker {
this.password = options.password;
this.beforeMiddleware = options.beforeMiddleware;
this.afterMiddleware = options.afterMiddleware;
this.sandboxGlobals = options.sandboxGlobals;
this.buildSandboxGlobals = options.buildSandboxGlobals;
this.chunkedResponse = options.chunkedResponse;

if (!this.httpServer) {
Expand All @@ -32,7 +32,7 @@ class Worker {
password: this.password,
beforeMiddleware: this.beforeMiddleware,
afterMiddleware: this.afterMiddleware,
sandboxGlobals: options.sandboxGlobals,
buildSandboxGlobals: options.buildSandboxGlobals,
});
}

Expand Down Expand Up @@ -74,7 +74,7 @@ class Worker {
buildMiddleware() {
this.fastboot = new FastBoot({
distPath: this.distPath,
sandboxGlobals: this.sandboxGlobals,
buildSandboxGlobals: this.buildSandboxGlobals,
});

return fastbootMiddleware({
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/dist-path-change-server.js
Expand Up @@ -35,7 +35,9 @@ const connector = new DownloaderNotifier({
var server = new FastBootAppServer({
notifier: connector,
downloader: connector,
sandboxGlobals: { THE_GLOBAL: MY_GLOBAL }
buildSandboxGlobals(defaultGlobals) {
return Object.assign({}, defaultGlobals, { THE_GLOBAL: MY_GLOBAL });
}
});

const serverPromise = server.start();
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/sandbox-globals-app-server.js
Expand Up @@ -7,7 +7,9 @@ const MY_GLOBAL = 'MY GLOBAL';

var server = new FastBootAppServer({
distPath: path.resolve(__dirname, './global-app'),
sandboxGlobals: { THE_GLOBAL: MY_GLOBAL }
buildSandboxGlobals(defaultGlobals) {
return Object.assign({}, defaultGlobals, { THE_GLOBAL: MY_GLOBAL });
}
});

server.start();

0 comments on commit 4e80446

Please sign in to comment.