Skip to content

Commit

Permalink
add large body test
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Nov 9, 2024
1 parent e0489b5 commit ae05f33
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/tests/middlewares/body-json-large.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// must support json body parser with large body

const express = require("express");
const bodyParser = require("body-parser");

const app = express();

app.use(bodyParser.json({ limit: '10mb' }));

app.post('/abc', (req, res) => {
res.send({ result: req.body?.items?.length });
});

app.listen(13333, async () => {
console.log('Server is running on port 13333');

const response = await fetch('http://localhost:13333/abc', {
method: 'POST',
body: JSON.stringify({ items: Array(100_000).fill().map((_, i) => i + 1) }),
headers: {
'Content-Type': 'application/json'
}
});
const text = await response.text();
console.log(text);

process.exit(0);

});

0 comments on commit ae05f33

Please sign in to comment.