diff --git a/index.js b/index.js index e85a93cc..128bd29b 100644 --- a/index.js +++ b/index.js @@ -42,8 +42,7 @@ module.exports = { _fastbootRenderingMiddleware(app) { - app.use(bodyParser.json()); - app.post('/__mock-request', (req, res) => { + app.post('/__mock-request', bodyParser.json(), (req, res) => { let mock = nock(req.headers.origin) .persist() .intercept(req.body.path, req.body.method) @@ -118,6 +117,13 @@ module.exports = { res.json({ err: jsonError }); }); }); + + if (this.app.name === "dummy") { + // our dummy app has an echo endpoint! + app.post('/fastboot-testing/echo', bodyParser.text(), (req, res) => { + res.send(req.body); + }); + } }, postBuild(result) { diff --git a/tests/dummy/app/pods/examples/network/other/echo/controller.js b/tests/dummy/app/pods/examples/network/other/echo/controller.js new file mode 100644 index 00000000..72c4bc3f --- /dev/null +++ b/tests/dummy/app/pods/examples/network/other/echo/controller.js @@ -0,0 +1,5 @@ +import Controller from '@ember/controller'; + +export default Controller.extend({ + queryParams: ['message'] +}); diff --git a/tests/dummy/app/pods/examples/network/other/echo/route.js b/tests/dummy/app/pods/examples/network/other/echo/route.js new file mode 100644 index 00000000..c59fac70 --- /dev/null +++ b/tests/dummy/app/pods/examples/network/other/echo/route.js @@ -0,0 +1,20 @@ +import Route from '@ember/routing/route'; +import fetch from 'fetch'; + +export default Route.extend({ + + // this endpoint is defined in index.js, it's used to represent + // a url that ember-cli might already have in it's express router. + + // we should be able to post a body to this echo endpoint and + // get a reply back. + model(params) { + return fetch('/fastboot-testing/echo', { + method: 'POST', + body: params.message + }).then(response => { + return response.text(); + }); + } + +}); diff --git a/tests/dummy/app/pods/examples/network/other/echo/template.hbs b/tests/dummy/app/pods/examples/network/other/echo/template.hbs new file mode 100644 index 00000000..fb6e7c6a --- /dev/null +++ b/tests/dummy/app/pods/examples/network/other/echo/template.hbs @@ -0,0 +1 @@ +