Skip to content

Commit 4e80446

Browse files
author
Robert Jackson
authored
Merge pull request #124 from zonkyio/update-fastboot-3
2 parents 32e5418 + 82362c9 commit 4e80446

File tree

7 files changed

+473
-66
lines changed

7 files changed

+473
-66
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ let server = new FastBootAppServer({
4343
gzip: true, // Optional - Enables gzip compression.
4444
host: '0.0.0.0', // Optional - Sets the host the server listens on.
4545
port: 4000, // Optional - Sets the port the server listens on (defaults to the PORT env var or 3000).
46-
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"
46+
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"
47+
return Object.assign({}, defaultGlobals, { GLOBAL_VALUE: MY_GLOBAL });
48+
},
4749
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.
4850
});
4951

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"chalk": "^2.0.1",
3131
"compression": "^1.6.2",
3232
"express": "^4.13.3",
33-
"fastboot": "^2.0.0",
34-
"fastboot-express-middleware": "^2.0.0"
33+
"fastboot": "^3.1.1",
34+
"fastboot-express-middleware": "^3.0.0"
3535
},
3636
"devDependencies": {
3737
"chai": "^4.1.0",

src/fastboot-app-server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class FastBootAppServer {
2323
this.httpServer = options.httpServer;
2424
this.beforeMiddleware = options.beforeMiddleware;
2525
this.afterMiddleware = options.afterMiddleware;
26-
this.sandboxGlobals = options.sandboxGlobals;
26+
this.buildSandboxGlobals = options.buildSandboxGlobals;
2727
this.chunkedResponse = options.chunkedResponse;
2828

2929
if (!this.ui) {
@@ -46,7 +46,7 @@ class FastBootAppServer {
4646
httpServer: this.httpServer,
4747
beforeMiddleware: this.beforeMiddleware,
4848
afterMiddleware: this.afterMiddleware,
49-
sandboxGlobals: this.sandboxGlobals,
49+
buildSandboxGlobals: this.buildSandboxGlobals,
5050
chunkedResponse: this.chunkedResponse,
5151
});
5252

src/worker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Worker {
1717
this.password = options.password;
1818
this.beforeMiddleware = options.beforeMiddleware;
1919
this.afterMiddleware = options.afterMiddleware;
20-
this.sandboxGlobals = options.sandboxGlobals;
20+
this.buildSandboxGlobals = options.buildSandboxGlobals;
2121
this.chunkedResponse = options.chunkedResponse;
2222

2323
if (!this.httpServer) {
@@ -32,7 +32,7 @@ class Worker {
3232
password: this.password,
3333
beforeMiddleware: this.beforeMiddleware,
3434
afterMiddleware: this.afterMiddleware,
35-
sandboxGlobals: options.sandboxGlobals,
35+
buildSandboxGlobals: options.buildSandboxGlobals,
3636
});
3737
}
3838

@@ -74,7 +74,7 @@ class Worker {
7474
buildMiddleware() {
7575
this.fastboot = new FastBoot({
7676
distPath: this.distPath,
77-
sandboxGlobals: this.sandboxGlobals,
77+
buildSandboxGlobals: this.buildSandboxGlobals,
7878
});
7979

8080
return fastbootMiddleware({

test/fixtures/dist-path-change-server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ const connector = new DownloaderNotifier({
3535
var server = new FastBootAppServer({
3636
notifier: connector,
3737
downloader: connector,
38-
sandboxGlobals: { THE_GLOBAL: MY_GLOBAL }
38+
buildSandboxGlobals(defaultGlobals) {
39+
return Object.assign({}, defaultGlobals, { THE_GLOBAL: MY_GLOBAL });
40+
}
3941
});
4042

4143
const serverPromise = server.start();

test/fixtures/sandbox-globals-app-server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ const MY_GLOBAL = 'MY GLOBAL';
77

88
var server = new FastBootAppServer({
99
distPath: path.resolve(__dirname, './global-app'),
10-
sandboxGlobals: { THE_GLOBAL: MY_GLOBAL }
10+
buildSandboxGlobals(defaultGlobals) {
11+
return Object.assign({}, defaultGlobals, { THE_GLOBAL: MY_GLOBAL });
12+
}
1113
});
1214

1315
server.start();

0 commit comments

Comments
 (0)