Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document bodyParserLimit option (#624) #1154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ const options = {
}
```

#### bodyParserLimit (or maximum POST body size)
Koop configures Express maximum body size to 10mb by default. If you want to decrease or increase that size, you can do so by adding a `bodyParserLimit` value to your Koop config file:

```js
const options = {
bodyParserLimit: '20mb'
}
```

> See [Supported units and abbreviations](https://www.npmjs.com/package/bytes#bytesparsestringnumber-value-numbernull).

#### logger
Koop includes a Winston logger with a console transport by default. If you have a custom logger that you want to use, you can pass it as an option:

Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const DataProvider = require('./data-provider');

const providerConstructorSpy = sinon.spy();

const mockBodyParser = {
json: sinon.spy(() => {}),
urlencoded: sinon.spy(() => {}),
};

const mockApp = {
use: sinon.spy(() => mockApp),
disable: sinon.spy(() => mockApp),
Expand Down Expand Up @@ -44,6 +49,7 @@ const Koop = proxyquire('./', {
'./data-provider': mockDataProviderModule,
'@koopjs/logger': MockLogger,
express: mockExpress,
'body-parser': mockBodyParser,
});

class MockProviderPluginController {
Expand Down Expand Up @@ -91,6 +97,7 @@ describe('Index tests', function () {
const koop = new Koop();
koop.config.should.be.empty();
mockApp.use.callCount.should.equal(5);
mockBodyParser.json.calledWith({ limit: '10000kb' });
});

it('should instantiate Koop with options', function () {
Expand All @@ -109,6 +116,13 @@ describe('Index tests', function () {

mockApp.use.callCount.should.equal(3);
});

it('should modify bodyParserLimit', function () {
new Koop({ bodyParserLimit: '20mb' });

mockApp.use.callCount.should.equal(5);
mockBodyParser.json.calledWith({ limit: '20mb' });
});
});

describe('Plugin registration', function () {
Expand Down