feathersjs/feathers-generator

View on GitHub
examples/app/src/middleware/body-parser.js

Summary

Maintainability
A
3 hrs
Test Coverage
'use strict';

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

export default function (options = {}) {
  const json = bodyParser.json();
  const urlencoded = bodyParser.urlencoded({
    extended: options.extended
  });

  return function (req, res, next) {
    json(req, res, function (error) {
      if (error) {
        return next(error);
      }

      urlencoded(req, res, next);
    });
  };
}