Closed cfrome77 closed 3 years ago
https://codesandbox.io/s/moleculer-issue-236-pl83k You can solve your problem in this way, separating the file upload and other requests at the route level.
@intech thanks for the reply and the codesandbox example. The example is extremly helpful. Separating the paths at the route level looks like exactly what I should be doing.
@intech the sand box is not working anymore. Do u have the code uploaded anywhere ?
@Canario0 I can't write a new code example right now.
Routes have a global path
in settings and have a path
into each group of routes with custom settings https://moleculer.services/docs/0.14/moleculer-web.html#File-upload-aliases.
First, you need to designate a common Path for all routes. And then, inside the routes array, separate them and set different bodyParser
and aliases settings https://moleculer.services/docs/0.14/moleculer-web.html#Multiple-routes.
Using examples from the documentation and small tests, you can figure it out yourself.
when using moleculer-web as an apiGateway is it possible to disable bodyParsers for specific aliases on a route path? If not is possible that a new route be created with the same path and implement a whitlelist for the specific endpoint? There are service files with actions in the implementation that all use the /api route path.
A servie file with an actions was implemented to upload files (/api/v1/upload) and as the documentation mentions needs to have bodyParsers disabled. I would like for the other api path routes (api/v1/permissions, api/v1/user, etc...) to be able to continue using the bodyParsers functionality. Please let me know what I may be missing. Currently when I try to call the action (api/v1/upload) the params in ctx comes back as empty, yet the 200 response in swagger shows the data in the browser network. Currently the service file is just printing the ctx to make sure the file data is coming back, which it is currently not.
ctx showing empty param object
/api routes path in api.service.js
file.service.js