Skip to content

Commit

Permalink
changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Dec 4, 2024
1 parent 7328ad7 commit 3d0b316
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
<a name="0.11.0-beta1"></a>
# 0.11.0-beta1 (2024-12-04)

## Changes

### Using 0.15 new streaming solution

The moleculer-web@0.11.x supports Moleculer v0.15.x including the new streaming solution. It means, it doesn't support 0.13 and 0.14 moleculer versions.

Thanks for the new solution, the multipart fields and request parameters are sent via `ctx.params` instead of meta and the file stream is available in `ctx.stream` in action handlers.

**Example**

```js
module.exports = {
name: "file",
actions: {
save: {
handler(ctx) {
return new this.Promise((resolve, reject) => {
const filePath = path.join(uploadDir, ctx.params.$filename);
const f = fs.createWriteStream(filePath);
f.on("close", () => {
// File written successfully
this.logger.info(`Uploaded file stored in '${filePath}'`);
resolve({ filePath });
});

ctx.stream.on("error", err => {
this.logger.info("File error received", err.message);
reject(err);

// Destroy the local file
f.destroy(err);
});

f.on("error", () => {
// Remove the errored file.
fs.unlinkSync(filePath);
});

ctx.stream.pipe(f);
});
}
}
}
};
```

Example content of `ctx.params`:

```json
{
// Multipart file properties
$fieldname: "myfile",
$filename: "avatar.png",
$encoding: "7bit",
$mimetype: "image/png",

// Other multipart fields
// e.g.: `<input type="text" name="name" id="name" value="Test User">`
name: "Test User",

// Request path parameter, e.g.: `/upload/single/1234`
id: "1234"
}
```


-----------------------------
<a name="0.10.7"></a>
# 0.10.7 (2023-11-12)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"webpack-dev-middleware": "^5.2.1"
},
"peerDependencies": {
"moleculer": "^0.13.0 || ^0.14.0 || ^0.15.0"
"moleculer": "^0.15.0"
},
"dependencies": {
"@fastify/busboy": "^1.0.0",
Expand Down

0 comments on commit 3d0b316

Please sign in to comment.