body parser


1. Simple JSON parsing

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

const app = express();
app.use(bodyParser.json());

app.post('/json', (req, res) => {
  console.log(req.body);
  res.send('OK');
});

2. Parsing extended forms (with file uploads)

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

const app = express();
app.use(bodyParser.urlencoded({ extended: true }));

app.post('/form', (req, res) => {
  console.log(req.body);
  res.send('OK');
});

3. Limiting the size of request bodies

4. Type-checking request bodies

5. Customizing the error handling middleware

6. Using multiple middlewares

7. Parsing raw text bodies

8. Parsing multipart/form-data

9. Using the raw API

10. Using the text API

11. Parsing and verifying JSON Web Tokens (JWTs)

12. Parsing and validating GraphQL queries

13. Parsing and validating Protobuf messages

14. Using the form-data API

15. Using the urlencoded API

16. Using the json API

17. Using the raw API with a custom encoding

18. Parsing JSON without a Content-Type header

19. Parsing JSON from a POST request with no body

20. Parsing JSON from an X-Forwarded-Raw request body

21. Parsing JSON using a custom type

22. Parsing JSON with a depth limit

23. Parsing JSON with a reviver function

24. Using the formidable middleware

25. Using the multer middleware