Skip to content

Commit 6196774

Browse files
authored
Remove unused "fastboot" code (#7301)
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 6196774

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,

0 commit comments

Comments
 (0)