Skip to content

Commit

Permalink
Simplify middleware used in tests to parse the body
Browse files Browse the repository at this point in the history
In preparation of the docs, I've simplified it so it's more idiomatic.
  • Loading branch information
cibernox committed Jul 31, 2017
1 parent 460099a commit d3e144b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
17 changes: 4 additions & 13 deletions test/fixtures/request/lib/post-middleware/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
var bodyParser = require('body-parser');
var FastBootExpressMiddleware = require('fastboot-express-middleware');
var FastBoot = require('fastboot');

module.exports = {
name: 'post-middleware',

serverMiddleware: function(options) {
serverMiddleware(options) {
var app = options.app;
app.use(bodyParser.text());
app.use(function(req, resp, next) {
var broccoliHeader = req.headers['x-broccoli'];
var outputPath = broccoliHeader['outputPath'];

if (req.method === 'POST') {

if (!this.fastboot) {
this.fastboot = new FastBoot({
distPath: outputPath
});
}
if (req.serveUrl) {
var outputPath = req.headers['x-broccoli']['outputPath']

var fastbootMiddleware = FastBootExpressMiddleware({
fastboot: this.fastboot
distPath: outputPath
});

fastbootMiddleware(req, resp, next);
Expand Down
5 changes: 0 additions & 5 deletions test/fixtures/request/lib/post-middleware/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"name": "post-middlware",
"ember-addon": {
"after": [
"ember-cli-fastboot"
]
},
"keywords": [
"ember-addon"
]
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3526,11 +3526,11 @@ http-signature@~1.1.0:
jsprim "^1.2.2"
sshpk "^1.7.0"

iconv-lite@0.4.15:
iconv-lite@0.4.15, iconv-lite@~0.4.13:
version "0.4.15"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb"

iconv-lite@^0.4.17, iconv-lite@^0.4.5, iconv-lite@~0.4.13:
iconv-lite@^0.4.17, iconv-lite@^0.4.5:
version "0.4.17"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.17.tgz#4fdaa3b38acbc2c031b045d0edcdfe1ecab18c8d"

Expand Down

0 comments on commit d3e144b

Please sign in to comment.