Skip to content

Commit

Permalink
fix: moleculer web errata
Browse files Browse the repository at this point in the history
  see [moleculer-web/issues/#308](moleculerjs/moleculer-web#308)
  • Loading branch information
furanzujin committed Apr 20, 2022
1 parent 16dbe3f commit 52c2649
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions source/docs/0.14/moleculer-web.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ You can't request the `/math.add` or `/math/add` URLs, only `POST /add`.
### File upload aliases
API Gateway has implemented file uploads. You can upload files as a multipart form data (thanks to [busboy](https://github.com/mscdex/busboy) library) or as a raw request body. In both cases, the file is transferred to an action as a `Stream`. In multipart form data mode you can upload multiple files, as well.

{% note warn %}
Please note, you have to disable other body parsers in order to accept files.
{% endnote %}

**Example**
```js
const ApiGateway = require("moleculer-web");
Expand All @@ -231,12 +227,6 @@ module.exports = {
{
path: "",

// You should disable body parsers
bodyParsers: {
json: false,
urlencoded: false
},

aliases: {
// File upload from HTML multipart form
"POST /": "multipart:file.save",
Expand Down Expand Up @@ -273,8 +263,8 @@ module.exports = {

In order to access the files passed by multipart-form these specific fields can be used inside the action:
- `ctx.params` is the Readable stream containing the file passed to the endpoint
- `ctx.params.$params` parameters from URL querystring
- `ctx.meta.$multipart` contains the additional text form-data fields passed _before other files fields_.
- `ctx.meta.$params` parameters from URL querystring
- `ctx.meta.$multipart` contains the additional text form-data fields _must be sent before other files fields_.

### Auto-alias
The auto-alias feature allows you to declare your route alias directly in your services. The gateway will dynamically build the full routes from service schema.
Expand Down

0 comments on commit 52c2649

Please sign in to comment.