Skip to content

Commit d4be431

Browse files
jasonmitoffirgolan
authored andcommitted
feat: Make recording size limit configurable (#40)
1 parent 730e5f2 commit d4be431

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

docs/node-server/overview.md

+17
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,20 @@ registerExpressAPI(app, {
122122
apiNamespace: 'polly_js'
123123
});
124124
```
125+
126+
### recordingSizeLimit
127+
128+
_Type_: `String`
129+
_Default_: `'50mb'`
130+
131+
A recording size can not exceed 50mb by default. If your application exceeds this limit, bump this value to a reasonable limit.
132+
133+
```js
134+
new Server({
135+
recordingSizeLimit: '50mb'
136+
});
137+
138+
registerExpressAPI(app, {
139+
recordingSizeLimit: '50mb'
140+
});
141+
```

packages/@pollyjs/cli/bin/cli.js

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ cli
2525
'recordings directory',
2626
Polly.Defaults.recordingsDir
2727
)
28+
.option(
29+
'-s, --recording-size-limit <limit>',
30+
'recording size limit',
31+
Polly.Defaults.recordingSizeLimit
32+
)
2833
.option('-q, --quiet', 'disable the logging')
2934
.action(function(options) {
3035
new Polly.Server(options).listen();

packages/@pollyjs/ember/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ module.exports = function(defaults) {
3838
// Server Configuration Options
3939
server: {
4040
apiNamespace: 'polly',
41-
recordingsDir: 'recordings'
41+
recordingsDir: 'recordings',
42+
recordingSizeLimit: '50mb'
4243
}
4344
}
4445
});
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export default {
22
port: 3000,
33
quiet: false,
4+
recordingSizeLimit: '50mb',
45
recordingsDir: 'recordings',
56
apiNamespace: 'polly'
67
};

packages/@pollyjs/node-server/src/express/register-api.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ export default function registerAPI(app, config) {
3434
}
3535
});
3636

37-
router.post('/:recording', bodyParser.json(), function(req, res) {
38-
const { recording } = req.params;
39-
const { status, body } = api.saveRecording(recording, req.body);
40-
41-
res.status(status).send(body);
42-
});
37+
router.post(
38+
'/:recording',
39+
bodyParser.json({ limit: config.recordingSizeLimit }),
40+
function(req, res) {
41+
const { recording } = req.params;
42+
const { status, body } = api.saveRecording(recording, req.body);
43+
44+
res.status(status).send(body);
45+
}
46+
);
4347

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

0 commit comments

Comments
 (0)