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

fix: moleculer web errata #175

Merged
merged 1 commit into from
Apr 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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