Skip to content

Commit

Permalink
feat: Make recording size limit configurable (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmit authored and offirgolan committed Jun 23, 2018
1 parent 730e5f2 commit d4be431
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
17 changes: 17 additions & 0 deletions docs/node-server/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,20 @@ registerExpressAPI(app, {
apiNamespace: 'polly_js'
});
```

### recordingSizeLimit

_Type_: `String`
_Default_: `'50mb'`

A recording size can not exceed 50mb by default. If your application exceeds this limit, bump this value to a reasonable limit.

```js
new Server({
recordingSizeLimit: '50mb'
});

registerExpressAPI(app, {
recordingSizeLimit: '50mb'
});
```
5 changes: 5 additions & 0 deletions packages/@pollyjs/cli/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ cli
'recordings directory',
Polly.Defaults.recordingsDir
)
.option(
'-s, --recording-size-limit <limit>',
'recording size limit',
Polly.Defaults.recordingSizeLimit
)
.option('-q, --quiet', 'disable the logging')
.action(function(options) {
new Polly.Server(options).listen();
Expand Down
3 changes: 2 additions & 1 deletion packages/@pollyjs/ember/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module.exports = function(defaults) {
// Server Configuration Options
server: {
apiNamespace: 'polly',
recordingsDir: 'recordings'
recordingsDir: 'recordings',
recordingSizeLimit: '50mb'
}
}
});
Expand Down
1 change: 1 addition & 0 deletions packages/@pollyjs/node-server/src/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default {
port: 3000,
quiet: false,
recordingSizeLimit: '50mb',
recordingsDir: 'recordings',
apiNamespace: 'polly'
};
16 changes: 10 additions & 6 deletions packages/@pollyjs/node-server/src/express/register-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ export default function registerAPI(app, config) {
}
});

router.post('/:recording', bodyParser.json(), function(req, res) {
const { recording } = req.params;
const { status, body } = api.saveRecording(recording, req.body);

res.status(status).send(body);
});
router.post(
'/:recording',
bodyParser.json({ limit: config.recordingSizeLimit }),
function(req, res) {
const { recording } = req.params;
const { status, body } = api.saveRecording(recording, req.body);

res.status(status).send(body);
}
);

router.delete('/:recording', function(req, res) {
const { recording } = req.params;
Expand Down

0 comments on commit d4be431

Please sign in to comment.