Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

How to set options.strict to false #102

Closed
dereklin opened this issue Sep 26, 2019 · 2 comments
Closed

How to set options.strict to false #102

dereklin opened this issue Sep 26, 2019 · 2 comments

Comments

@dereklin
Copy link
Contributor

In dyson/node_modules/body-parser/lib/types/json.js, I see this function:

/**
 * Create a middleware to parse JSON bodies.
 *
 * @param {object} [options]
 * @return {function}
 * @public
 */

function json(options) {
    var opts = options || {};

    var limit =
        typeof opts.limit !== "number"
            ? bytes.parse(opts.limit || "100kb")
            : opts.limit;
    var inflate = opts.inflate !== false;
    var reviver = opts.reviver;
    var strict = opts.strict !== false;

I am trying to figure out how to set strict to false. I have tried custom middleware and dyson.json but haven't had any luck.

Could you point me to an example?

@dereklin
Copy link
Contributor Author

I found this source code in https://github.com/webpro/dyson/blob/master/lib/dyson.js:

const installMiddleware = (app, options) => {
  const bodyParserOptions = options.bodyParserJsonLimit ? { limit: options.bodyParserJsonLimit } : {};
  const bodyParserUrlOptions = { extended: true };
  bodyParserUrlOptions.limit = options.bodyParserUrlencodedLimit ? options.bodyParserUrlencodedLimit : null;

  app.use(cors({ origin: true, credentials: true }));
  app.use(rawBody());
  app.use(cookieParser());
  app.use(favicon(`${__dirname}/favicon.ico`));
  app.use(bodyParser.json(bodyParserOptions));
  app.use(bodyParser.urlencoded(bodyParserUrlOptions));

  return app;
};

Does it mean only bodyParserJsonLimit is supported?

@webpro
Copy link
Owner

webpro commented Oct 1, 2019

Resolved by #103

@webpro webpro closed this as completed Oct 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants