Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs: document bodyParserLimit option (#624)#1154

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
brightgarden wants to merge1 commit intokoopjs:master
base:master
Choose a base branch
Loading
frombrightgarden:docs/body-parser-limit-option
Open
Show file tree
Hide file tree
Changes fromall 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
docs: document bodyParserLimit option (#624)
Added documentation for koop option `bodyParserLimit` (for POST maximum body size). Also added someunit tests.
  • Loading branch information
@ns-mwoo
ns-mwoo committedDec 21, 2024
commit01acabd2bd79e24e2245a33142966a8f0071fbf0
11 changes: 11 additions & 0 deletionspackages/core/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionspackages/core/src/index.spec.js
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand Up@@ -44,6 +49,7 @@ const Koop = proxyquire('./', {
'./data-provider': mockDataProviderModule,
'@koopjs/logger': MockLogger,
express: mockExpress,
'body-parser': mockBodyParser,
});

class MockProviderPluginController {
Expand DownExpand 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

[8]ページ先頭

©2009-2025 Movatter.jp