Skip to content

Commit 9f5b056

Browse files
committed
Merge remote-tracking branch 'local/fastboot-express-middleware/master'
2 parents f67d7a0 + a3457b4 commit 9f5b056

72 files changed

Lines changed: 437877 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/**
2+
test/fixtures/**
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
module.exports = {
3+
parserOptions: {
4+
ecmaVersion: 2017,
5+
},
6+
extends: ['eslint:recommended', 'plugin:node/recommended', 'plugin:prettier/recommended'],
7+
plugins: ['node', 'prettier'],
8+
env: {
9+
node: true,
10+
es6: true,
11+
},
12+
overrides: [
13+
{
14+
files: ['test/**/*-test.js'],
15+
env: {
16+
mocha: true,
17+
},
18+
extends: ['plugin:mocha/recommended'],
19+
plugins: ['mocha'],
20+
},
21+
],
22+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [10.x, 12.x, 14.x]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- run: yarn install --frozen-lockfile
24+
- run: yarn test
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
.eslintcache
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
test
2+
.gitignore
3+
.eslintcache
4+
.eslintignore
5+
.eslintrc.js
6+
.travis.yml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"printWidth": 100,
4+
"trailingComma": "es5"
5+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## v3.1.0 (2020-11-20)
2+
3+
#### :rocket: Enhancement
4+
* [#66](https://github.com/ember-fastboot/fastboot-express-middleware/pull/66) Add support for passing metadata into visitOptions of fastboot visit ([@suchitadoshi1987](https://github.com/suchitadoshi1987))
5+
6+
#### Committers: 1
7+
- Suchita Doshi ([@suchitadoshi1987](https://github.com/suchitadoshi1987))
8+
9+
10+
## v3.0.0 (2020-10-23)
11+
12+
#### :boom: Breaking Change
13+
* [#70](https://github.com/ember-fastboot/fastboot-express-middleware/pull/70) Update to [email protected] ([@rwjblue](https://github.com/rwjblue))
14+
* [#67](https://github.com/ember-fastboot/fastboot-express-middleware/pull/67) Drop Node 8 and 13 support. ([@rwjblue](https://github.com/rwjblue))
15+
* [#49](https://github.com/ember-fastboot/fastboot-express-middleware/pull/49) Drop support for Node 4, 6, 9, and 11. ([@sdhull](https://github.com/sdhull))
16+
17+
#### :rocket: Enhancement
18+
* [#70](https://github.com/ember-fastboot/fastboot-express-middleware/pull/70) Update to [email protected] ([@rwjblue](https://github.com/rwjblue))
19+
20+
#### :bug: Bug Fix
21+
* [#60](https://github.com/ember-fastboot/fastboot-express-middleware/pull/60) Use append to support multi-value headers ([@bobisjan](https://github.com/bobisjan))
22+
* [#54](https://github.com/ember-fastboot/fastboot-express-middleware/pull/54) Move `request` package into `devDependencies` ([@bobisjan](https://github.com/bobisjan))
23+
24+
#### :house: Internal
25+
* [#69](https://github.com/ember-fastboot/fastboot-express-middleware/pull/69) Add release automation setup. ([@rwjblue](https://github.com/rwjblue))
26+
* [#68](https://github.com/ember-fastboot/fastboot-express-middleware/pull/68) Migrate to GitHub Actions for CI ([@rwjblue](https://github.com/rwjblue))
27+
* [#64](https://github.com/ember-fastboot/fastboot-express-middleware/pull/64) Use async/await in tests ([@bobisjan](https://github.com/bobisjan))
28+
* [#56](https://github.com/ember-fastboot/fastboot-express-middleware/pull/56) Add Prettier ([@bobisjan](https://github.com/bobisjan))
29+
* [#55](https://github.com/ember-fastboot/fastboot-express-middleware/pull/55) Migrate to ESLint ([@bobisjan](https://github.com/bobisjan))
30+
* [#53](https://github.com/ember-fastboot/fastboot-express-middleware/pull/53) Remove Babel ([@bobisjan](https://github.com/bobisjan))
31+
32+
#### Committers: 3
33+
- Jan Bobisud ([@bobisjan](https://github.com/bobisjan))
34+
- Robert Jackson ([@rwjblue](https://github.com/rwjblue))
35+
- Steve ([@sdhull](https://github.com/sdhull))
36+
37+
38+
# fastboot-express-middleware Changelog
39+
40+
### 2.0.0
41+
* [BREAKING CHANGE] Bump FastBoot 1.x -> 2.x
42+
43+
### 1.2.0
44+
45+
* Bump `fastboot` version to 1.2.0.
46+
47+
### 1.1.1
48+
49+
* Enable chunked responses via a configuration option.
50+
51+
### 1.1.0
52+
53+
* Bumping `fastboot` version to 1.1.0
54+
* Bumping `mocha` version to 4.0.0
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# FastBoot Express Middleware
2+
3+
[![Greenkeeper badge](https://badges.greenkeeper.io/ember-fastboot/fastboot-express-middleware.svg)](https://greenkeeper.io/)
4+
5+
[![Build Status](https://travis-ci.org/ember-fastboot/fastboot-express-middleware.svg?branch=master)](https://travis-ci.org/ember-fastboot/fastboot-express-middleware)
6+
7+
This middleware is a small wrapper around the
8+
[fastboot](https://github.com/ember-fastboot/fastboot) package, which
9+
renders Ember.js apps in Node.js.
10+
11+
By adding this middleware to your Express app, you can serve HTML from a
12+
rendered Ember.js app to clients that don't support JavaScript, such as
13+
`curl`, search crawlers, or users with JavaScript disabled.
14+
15+
Note that this is _just an Express middleware_ and there is more needed
16+
to serve apps in a production environment. If you want to server-side
17+
rendered Ember applications without doing a lot of work, you are
18+
recommended to consider the [FastBoot App
19+
Server](https://github.com/ember-fastboot/fastboot-app-server), which
20+
manages many of the hard parts for you.
21+
22+
That said, this middleware is designed to be easy to integrate for those
23+
who already have existing Express stacks, or who want maximum
24+
flexibility in how requests are handled.
25+
26+
## Usage
27+
28+
```js
29+
const express = require('express');
30+
const fastbootMiddleware = require('fastboot-express-middleware');
31+
32+
let app = express();
33+
34+
app.get('/*', fastbootMiddleware('/path/to/dist'));
35+
36+
app.listen(3000, function () {
37+
console.log('FastBoot app listening on port 3000!');
38+
});
39+
```
40+
41+
## Building Your Ember App
42+
43+
Before you can use your app with FastBoot, you must first install the
44+
[ember-cli-fastboot][ember-cli-fastboot] addon and build your app by
45+
running `ember build`. The build process will compile your app into a
46+
version that is compatible with both Node.js and the browser and put it
47+
in the `dist` directory. This `dist` directory is the path you should
48+
provide to the middleware to specify which Ember app to load and render.
49+
50+
## Resilient Mode
51+
52+
By default, errors during render will cause the middleware to send an
53+
HTTP 500 status code as the response. In order to swallow errors and
54+
return a `200` status code with an empty HTML page, set the `resilient` flag to
55+
true:
56+
57+
```js
58+
app.get('/*', fastbootMiddleware({
59+
distPath: '/path/to/dist',
60+
resilient: true
61+
}));
62+
```
63+
64+
Resilient mode still calls `next(err)` to propagate your error to any subsequent
65+
middleware that you apply after this one.
66+
You can use this feature to track errors or log analytics.
67+
68+
However, because FastBoot is reslient still sends the response to the client.
69+
***You cannot alter the `response`*** with any of your post-fastboot middleware.
70+
71+
## Custom FastBoot Instance
72+
73+
For more control over the FastBoot instance that is created to render
74+
the Ember app, you can pass a custom instance that the middleware will
75+
use instead of creating its own:
76+
77+
```js
78+
let fastboot = new FastBoot({
79+
distPath: 'path/to/dist'
80+
});
81+
82+
let middleware = fastbootMiddleware({
83+
fastboot: fastboot
84+
});
85+
86+
app.get('/*', middleware);
87+
88+
// ...later
89+
fastboot.reload();
90+
```
91+
92+
## Response chunking
93+
94+
By default, the middleware writes the complete response at once but response
95+
chunking (aka HTTP Streaming) is available via a config switch:
96+
97+
```js
98+
app.get('/*', fastbootMiddleware({
99+
distPath: '/path/to/dist',
100+
chunkedResponse: true
101+
}));
102+
```
103+
104+
Enabling response chunking will result in the response being delivered in
105+
multiple chunks (one for the head, one for the body and one for each shoebox)
106+
which helps getting the HTML to clients faster.
107+
108+
[ember-cli-fastboot]: https://github.com/ember-fastboot/ember-cli-fastboot
109+
110+
## VisitOptions
111+
112+
For sending over additional metadata so that it could be leveraged by the consuming app/addon, you can pass the `visitOptions` option that contains any extra information that might be necessary.
113+
114+
Example usecase: If an addon relies on some metadata that is set by the consuming app, then in that case the addon will not have the access to the metadata value. In such cases, developing against dummy app becomes difficult. Hence, passing in the `visitOptions` will enable smoother local addon development.
115+
116+
```js
117+
app.get('/*', fastbootMiddleware({
118+
distPath: '/path/to/dist',
119+
visitOptions: {
120+
metadata: {
121+
foo: 'bar'
122+
}
123+
}
124+
}));
125+
```
126+
127+
## Tests
128+
129+
`npm test`
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Release Process
2+
3+
Releases are mostly automated using
4+
[release-it](https://github.com/release-it/release-it/) and
5+
[lerna-changelog](https://github.com/lerna/lerna-changelog/).
6+
7+
## Preparation
8+
9+
Since the majority of the actual release process is automated, the primary
10+
remaining task prior to releasing is confirming that all pull requests that
11+
have been merged since the last release have been labeled with the appropriate
12+
`lerna-changelog` labels and the titles have been updated to ensure they
13+
represent something that would make sense to our users. Some great information
14+
on why this is important can be found at
15+
[keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall
16+
guiding principle here is that changelogs are for humans, not machines.
17+
18+
When reviewing merged PR's the labels to be used are:
19+
20+
* breaking - Used when the PR is considered a breaking change.
21+
* enhancement - Used when the PR adds a new feature or enhancement.
22+
* bug - Used when the PR fixes a bug included in a previous release.
23+
* documentation - Used when the PR adds or updates documentation.
24+
* internal - Used for internal changes that still require a mention in the
25+
changelog/release notes.
26+
27+
## Release
28+
29+
Once the prep work is completed, the actual release is straight forward:
30+
31+
* First, ensure that you have installed your projects dependencies:
32+
33+
```sh
34+
yarn install
35+
```
36+
37+
* Second, ensure that you have obtained a
38+
[GitHub personal access token][generate-token] with the `repo` scope (no
39+
other permissions are needed). Make sure the token is available as the
40+
`GITHUB_AUTH` environment variable.
41+
42+
For instance:
43+
44+
```bash
45+
export GITHUB_AUTH=abc123def456
46+
```
47+
48+
[generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable
49+
50+
* And last (but not least 😁) do your release.
51+
52+
```sh
53+
npx release-it
54+
```
55+
56+
[release-it](https://github.com/release-it/release-it/) manages the actual
57+
release process. It will prompt you to to choose the version number after which
58+
you will have the chance to hand tweak the changelog to be used (for the
59+
`CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging,
60+
pushing the tag and commits, etc.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"name": "fastboot-express-middleware",
3+
"version": "3.1.0",
4+
"description": "An Express middleware for rendering Ember apps with FastBoot",
5+
"keywords": [
6+
"fastboot",
7+
"ember",
8+
"express",
9+
"middleware"
10+
],
11+
"homepage": "https://github.com/ember-fastboot/fastboot-express-middleware#readme",
12+
"bugs": {
13+
"url": "https://github.com/ember-fastboot/fastboot-express-middleware/issues"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "git+https://github.com/ember-fastboot/fastboot-express-middleware.git"
18+
},
19+
"license": "MIT",
20+
"author": "Tom Dale <[email protected]>",
21+
"main": "src/index.js",
22+
"scripts": {
23+
"lint:js": "eslint --cache .",
24+
"test": "yarn lint:js && mocha"
25+
},
26+
"dependencies": {
27+
"chalk": "^2.0.1",
28+
"fastboot": "^3.1.1"
29+
},
30+
"devDependencies": {
31+
"chai": "^4.1.0",
32+
"chai-as-promised": "^7.1.1",
33+
"eslint": "^6.8.0",
34+
"eslint-config-prettier": "^6.9.0",
35+
"eslint-plugin-mocha": "^6.2.2",
36+
"eslint-plugin-node": "^11.0.0",
37+
"eslint-plugin-prettier": "^3.1.2",
38+
"express": "^4.13.4",
39+
"mocha": "^5.0.0",
40+
"prettier": "^1.19.1",
41+
"release-it": "^14.2.0",
42+
"release-it-lerna-changelog": "^3.0.0",
43+
"request": "^2.88.0",
44+
"request-promise": "^4.2.1"
45+
},
46+
"engines": {
47+
"node": "10.* || 12.* || >= 14"
48+
},
49+
"publishConfig": {
50+
"registry": "https://registry.npmjs.org"
51+
},
52+
"release-it": {
53+
"plugins": {
54+
"release-it-lerna-changelog": {
55+
"infile": "CHANGELOG.md",
56+
"launchEditor": true
57+
}
58+
},
59+
"git": {
60+
"tagName": "v${version}"
61+
},
62+
"github": {
63+
"release": true,
64+
"tokenRef": "GITHUB_AUTH"
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)