moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
291 stars 119 forks source link

Multipart: ctx.params.pipe is not a function #281

Closed Pitbi closed 2 years ago

Pitbi commented 2 years ago

Hello,

I just updated moleculer-web (0.9.1 to 0.10.3) and with this new version ctx.params.pipe is no longer defined.

My API gateway service:

routes: [
  ...,
  {
    path: 'medias',
    bodyParsers: {
      json: false,
      urlencoded: false,
    },
    aliases: {
      'POST /': {
        type: 'multipart',
        busboyConfig: {
          limits: { files: 10 },
        },
        action: 'mediasController.create',
      },
    },
    mappingPolicy: 'restrict',
  },
]

And in 'mediasController.create' action, ctx.params & ctx.meta are empties when I upload files as a multipart form data.

An idea?

Thx

Pitbi commented 2 years ago

Ok, I found my problem:

My routes are configured like this:

routes: [
   ...,
  {
    path: 'medias',
    bodyParsers: {
      json: false,
      urlencoded: false,
    },
    aliases: {
      'POST /': {
        type: 'multipart',
        busboyConfig: {
          limits: { files: 10 },
        },
        action: 'mediasController.create',
      },
   },
   mappingPolicy: 'restrict',
  },
  {
      path: 'medias',
      aliases: {
        'REST ': 'mediasController',
      },
    },
]

I deduce that, since the update, 'REST': 'mediasController' overwrites the previous route (path: medias => aliases POST /).

My bad! Sorry for inconvenience. I will therefore take this opportunity to say that I use moleculer on several production projects and that it's great! 😎