Skip to content

Commit

Permalink
Body parser removed. Fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
muratcorlu committed Jan 12, 2018
1 parent f4153dc commit c3e510f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.3 (2018-01-12)

### Features:

- Body parser removed from cli-connect-mocker. Because from v 1.3.5, connect-api-mocker supports parsing json requests internally.

## 1.0.2 (2017-09-08)

### Features:
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "cli-api-mocker",
"version": "1.0.2",
"version": "1.0.3",
"description": "CLI wrapper for connect-api-mocker",
"main": "src/index.js",
"dependencies": {
"body-parser": "^1.17.2",
"command-line-args": "^4.0.7",
"connect-api-mocker": "^1.3.1",
"connect-api-mocker": "^1.3.5",
"cors": "^2.8.4",
"express": "^4.15.4",
"http-proxy-middleware": "^0.17.4"
Expand Down
12 changes: 0 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ try {

app.use(cors())

// TOOD: Multipart request support https://github.com/muratcorlu/cli-api-mocker/issues/1
app.use(bodyParser.json())

for(var path in config.map) {

var conf = config.map[path];
Expand All @@ -71,15 +68,6 @@ for(var path in config.map) {
target: conf.proxy
}
}
conf.proxy.onProxyReq = function (proxyReq, req, res, options) {
if(req.body) {
// TOOD: Multipart request support https://github.com/muratcorlu/cli-api-mocker/issues/1
var bodyData = JSON.stringify(req.body);
proxyReq.setHeader('Content-Type','application/json');
proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));
proxyReq.write(bodyData);
}
}
app.use(path, proxy(conf.proxy));
}
}
Expand Down

0 comments on commit c3e510f

Please sign in to comment.