@nicolasparada/bodyparser-middleware

    0.5.2 • Public • Published

    @nicolasparada/bodyparser-middleware npm version dependencies

    Body Parser Middleware.

    Usage

    const framework = require('@nicolasparada/web-framework')
    const bodyparser = require('@nicolasparada/bodyparser-middleware')
    
    const app = framework()
    
    app.post('/json', bodyparser.json(), req => req.body)
    app.post('/multipart', bodyparser.multipart(), req => {
      // Files are at req.files
      return req.body
    })
    
    app.listen(80, '127.0.0.1', () => {
      console.log('Make a POST request to http://localhost/echo-body')
    })

    Options

    JSON

    • limit {number} Maximum bytes to parse. Defaults to (1024 ** 2) * 100 (1mB).
    • types {string[]} 'Content-Type' headers to handle. Defaults to:
      • application/json
      • application/json-patch+json
      • application/vnd.api+json
      • application/csp-report

    MULTIPART

    The multipart body parser uses formidable, so you can pass any options supported by it.

    Install

    npm i @nicolasparada/bodyparser-middleware

    DownloadsWeekly Downloads

    33

    Version

    0.5.2

    License

    MIT

    Last publish

    Collaborators

    • nicolasparada