mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-11-29 18:58:26 +08:00
chore: incr bodyParser body limit (#2591)
This commit is contained in:
parent
e5f5358be0
commit
185fccad65
@ -1,6 +1,7 @@
|
||||
import supertest from 'supertest';
|
||||
import { Application } from '../application';
|
||||
import { Plugin } from '../plugin';
|
||||
import longJson from './fixtures/long-json';
|
||||
|
||||
class MyPlugin extends Plugin {
|
||||
async load() {}
|
||||
@ -29,6 +30,7 @@ describe('application', () => {
|
||||
dataWrapping: false,
|
||||
registerActions: false,
|
||||
});
|
||||
|
||||
app.resourcer.registerActionHandlers({
|
||||
list: async (ctx, next) => {
|
||||
ctx.body = [1, 2];
|
||||
@ -50,6 +52,22 @@ describe('application', () => {
|
||||
return app.destroy();
|
||||
});
|
||||
|
||||
it('should request long json', async () => {
|
||||
app.resourcer.define({
|
||||
name: 'test',
|
||||
actions: {
|
||||
test: async (ctx, next) => {
|
||||
ctx.body = ctx.request.body;
|
||||
await next();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await agent.post('/api/test:test').send(longJson).set('Content-Type', 'application/json');
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
});
|
||||
|
||||
it('resourcer.define', async () => {
|
||||
app.resourcer.define({
|
||||
name: 'test',
|
||||
|
11
packages/core/server/src/__tests__/fixtures/long-json.ts
Normal file
11
packages/core/server/src/__tests__/fixtures/long-json.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export default {
|
||||
title: 'title',
|
||||
content: getLongString(),
|
||||
};
|
||||
|
||||
function getLongString() {
|
||||
const size = 2 * 1024 * 1024;
|
||||
const buffer = Buffer.alloc(size, 'a');
|
||||
const str = buffer.toString('utf-8');
|
||||
return str;
|
||||
}
|
@ -48,8 +48,12 @@ export function registerMiddlewares(app: Application, options: ApplicationOption
|
||||
);
|
||||
|
||||
if (options.bodyParser !== false) {
|
||||
const bodyLimit = '10mb';
|
||||
app.use(
|
||||
bodyParser({
|
||||
jsonLimit: bodyLimit,
|
||||
formLimit: bodyLimit,
|
||||
textLimit: bodyLimit,
|
||||
...options.bodyParser,
|
||||
}),
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user