Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to specify limit for raw parser #593

Open
gastonelhordoy opened this issue May 11, 2023 · 2 comments
Open

Allow to specify limit for raw parser #593

gastonelhordoy opened this issue May 11, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers stale webhooks

Comments

@gastonelhordoy
Copy link

When using the RawBodyMiddleware middleware, it doesn't allow to provide a configurable limit parameter.

@Injectable()
export class RawBodyMiddleware implements NestMiddleware {
  use(req: Request, res: Response, next: () => any) {
    raw({ type: '*/*' })(req, res, next);
  }
}

In case of large payloads, it could cause raw-body library to throw a PayloadTooLarge exception.

function readStream (stream, encoding, length, limit, callback) {
  var complete = false
  var sync = true

  // check the length and limit options.
  // note: we intentionally leave the stream paused,
  // so users should handle the stream themselves.
  if (limit !== null && length !== null && length > limit) {
    return done(createError(413, 'request entity too large', {
      expected: length,
      length: length,
      limit: limit,
      type: 'entity.too.large'
    }))
  }

Is there any way to work around this restriction?

@gastonelhordoy gastonelhordoy changed the title Allow to specify limit for raw parser Allow to specify limit for raw parser May 11, 2023
@underfisk
Copy link
Contributor

@gastonelhordoy I believe this could be tweaked and possibly allow developers to inject that and our module infer through DI. Do you think you could potentially push this feature? I would be happy to review and push but currently i do not have enough time to develop such feature

@underfisk underfisk added enhancement New feature or request good first issue Good for newcomers webhooks labels Jul 4, 2023
Copy link

github-actions bot commented Oct 2, 2024

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers stale webhooks
Projects
None yet
Development

No branches or pull requests

2 participants