Skip to content

Commit 1f2084d

Browse files
committed
Remove unused "fastboot" code
Ember.js "fastboot" allows us to server-render the app and send HTML over the wire. While this sounds good in theory, using it in practice has shown that it requires significantly more server-side resources and causes a lot of additional complexity. This part of the codebase hasn't been used for years and if we would move to server-side rendering then it probably would be combined with moving to a different framework/architecture. Thus it is time for the fastboot code and complexity to be removed from the codebase.
1 parent 1607579 commit 1f2084d

File tree

21 files changed

+112
-698
lines changed

21 files changed

+112
-698
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ module.exports = {
114114
'.eslintrc.js',
115115
'.template-lintrc.js',
116116
'ember-cli-build.js',
117-
'fastboot.js',
118117
'testem.js',
119118
'blueprints/*/index.js',
120119
'config/**/*.js',

app/adapters/application.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
import RESTAdapter from '@ember-data/adapter/rest';
2-
import { inject as service } from '@ember/service';
32

43
export default class ApplicationAdapter extends RESTAdapter {
5-
@service fastboot;
6-
74
namespace = 'api/v1';
85

9-
get headers() {
10-
if (this.fastboot.isFastBoot) {
11-
return { 'User-Agent': this.fastboot.request.headers.get('User-Agent') };
12-
}
13-
14-
return {};
15-
}
16-
176
handleResponse(status, headers, payload, requestData) {
187
if (typeof payload === 'string') {
198
try {

app/app.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import Resolver from 'ember-resolver';
66
import config from './config/environment';
77
import * as Sentry from './sentry';
88

9-
if (typeof FastBoot === 'undefined') {
10-
// eslint-disable-next-line unicorn/prefer-add-event-listener
11-
window.onerror = undefined;
12-
Sentry.init();
13-
}
9+
// eslint-disable-next-line unicorn/prefer-add-event-listener
10+
window.onerror = undefined;
11+
Sentry.init();
1412

1513
export default class App extends Application {
1614
modulePrefix = config.modulePrefix;

app/controllers/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import { inject as service } from '@ember/service';
55
import { dropTask } from 'ember-concurrency';
66
import { reads } from 'macro-decorators';
77

8+
import ajax from '../utils/ajax';
9+
810
export default class IndexController extends Controller {
9-
@service fetcher;
1011
@service store;
1112

1213
@reads('dataTask.lastSuccessful.value') model;
@@ -22,7 +23,7 @@ export default class IndexController extends Controller {
2223
}
2324

2425
dataTask = dropTask(async () => {
25-
let data = await this.fetcher.ajax('/api/v1/summary');
26+
let data = await ajax('/api/v1/summary');
2627

2728
addCrates(this.store, data.new_crates);
2829
addCrates(this.store, data.most_downloaded);

app/initializers/hashchange.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ function hashchange() {
3232
}
3333

3434
export function initialize() {
35-
if (typeof window === 'undefined' || window.addEventListener === undefined) {
36-
// Don't run this initializer under FastBoot
37-
return;
38-
}
3935
window.addEventListener('hashchange', hashchange);
4036

4137
// If clicking on a link to the same fragment as currently in the address bar,

app/routes/index.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import Route from '@ember/routing/route';
2-
import { inject as service } from '@ember/service';
32

43
export default class IndexRoute extends Route {
5-
@service fastboot;
6-
74
setupController(controller) {
85
if (!controller.hasData) {
9-
let promise = controller.fetchData();
10-
if (this.fastboot.isFastBoot) {
11-
this.fastboot.deferRendering(promise);
12-
}
6+
controller.fetchData();
137
}
148
}
159
}

app/services/design.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Service, { inject as service } from '@ember/service';
1+
import Service from '@ember/service';
22
import { tracked } from '@glimmer/tracking';
33

44
import config from '../config/environment';
@@ -7,8 +7,6 @@ import * as localStorage from '../utils/local-storage';
77
const KNOWN_THEMES = new Set(['classic', 'new-design']);
88

99
export default class DesignService extends Service {
10-
@service fastboot;
11-
1210
@tracked _theme = localStorage.getItem('theme');
1311
@tracked showToggleButton = config.environment === 'development' || config.environment === 'test';
1412

app/services/fetcher.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/services/redirector.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
import Service, { inject as service } from '@ember/service';
1+
import Service from '@ember/service';
22

33
import window from 'ember-window-mock';
44

55
export default class RedirectorService extends Service {
6-
@service fastboot;
7-
86
redirectTo(url) {
9-
if (this.fastboot.isFastBoot) {
10-
let headers = this.fastboot.response.headers;
11-
headers.set('location', url);
12-
this.set('fastboot.response.statusCode', 301);
13-
} else {
14-
window.location = url;
15-
}
7+
window.location = url;
168
}
179
}

config/environment.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ module.exports = function (environment) {
2323
// when it is created
2424
},
2525

26-
fastboot: {
27-
hostWhitelist: ['crates.io', /^localhost:\d+$/, /\.herokuapp\.com$/],
28-
},
29-
3026
'ember-cli-notifications': {
3127
autoClear: true,
3228
clearDuration: 10_000,

config/nginx.conf.erb

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -232,33 +232,8 @@ http {
232232
rewrite ^ https://$host$request_uri? permanent;
233233
}
234234

235-
<% if ENV['USE_FASTBOOT'] == "staging-experimental" %>
236-
# Experimentally send all non-backend requests to FastBoot
237-
238-
location /api/ {
239-
proxy_pass http://app_server;
240-
}
241-
242-
# FastBoot
243-
location / {
244-
proxy_pass http://localhost:9000;
245-
}
246-
<% elsif ENV['USE_FASTBOOT'] && !ENV['USE_FASTBOOT'].empty? %>
247-
# Fastboot is enabled only for allowed paths
248-
249-
location = /policies {
250-
proxy_pass http://localhost:9000;
251-
}
252-
253-
location / {
254-
proxy_pass http://app_server;
255-
}
256-
<% else %>
257-
# FastBoot is disabled, backend sends the static Ember index HTML for non-backend paths
258-
259-
location / {
260-
proxy_pass http://app_server;
261-
}
262-
<% end %>
235+
location / {
236+
proxy_pass http://app_server;
237+
}
263238
}
264239
}

fastboot.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
"lint:hbs": "ember-template-lint app",
2323
"lint:js": "eslint . --cache",
2424
"prettier": "prettier --write package.json '**/*.js'",
25-
"start": "./script/ember.sh serve",
26-
"start:live": "PROXY_BACKEND=https://crates.io ./script/ember.sh serve",
27-
"start:local": "PROXY_BACKEND=http://127.0.0.1:8888 ./script/ember.sh serve",
28-
"start:staging": "PROXY_BACKEND=https://staging-crates-io.herokuapp.com ./script/ember.sh serve",
25+
"start": "ember serve",
26+
"start:live": "PROXY_BACKEND=https://crates.io ember serve",
27+
"start:local": "PROXY_BACKEND=http://127.0.0.1:8888 ember serve",
28+
"start:staging": "PROXY_BACKEND=https://staging-crates-io.herokuapp.com ember serve",
2929
"test": "ember exam --split=2 --parallel",
3030
"test-coverage": "COVERAGE=true npm run test && ember coverage-merge && rm -rf coverage_* coverage/coverage-summary.json && nyc report"
3131
},
@@ -43,7 +43,6 @@
4343
"chart.js": "4.4.0",
4444
"copy-text-to-clipboard": "3.2.0",
4545
"date-fns": "2.30.0",
46-
"fastboot-app-server": "4.1.1",
4746
"highlight.js": "11.9.0",
4847
"macro-decorators": "0.1.2",
4948
"mermaid": "10.5.0",
@@ -82,7 +81,6 @@
8281
"ember-cli-dependency-checker": "3.3.2",
8382
"ember-cli-dependency-lint": "2.0.1",
8483
"ember-cli-deprecation-workflow": "2.1.0",
85-
"ember-cli-fastboot": "4.1.1",
8684
"ember-cli-head": "2.0.0",
8785
"ember-cli-htmlbars": "6.3.0",
8886
"ember-cli-inject-live-reload": "2.1.0",

0 commit comments

Comments
 (0)