Releases: moleculerjs/moleculer-web
v0.11.0-beta2
Changes
BREAKING: Minimum Node 20
The minimum Node version is Node 20.x.
BREAKING: Update dependencies
Many dependencies (major, minor, patch) is upgraded which can contain breaking changes
Full Changelog: v0.11.0-beta1...v0.11.0-beta2
v0.10.8
What's Changed
- imp(index.d.ts): correct onError req type by @0x0a0d in #349
- Update index.d.ts - export RateLimitStores/ApiGatewayErrors by @salisbury-espinosa in #360
- feat: added blacklist functionality for auto aliases by @jappyjan in #361
New Contributors
- @salisbury-espinosa made their first contribution in #360
- @jappyjan made their first contribution in #361
Full Changelog: v0.10.7...v0.10.8
v0.11.0-beta1
Full Changelog: v0.10.7...v0.11.0-beta1
Changes
Updated path-ro-regexp
library
The path-to-regexp
has been updated to 8.x.x. It contains many breaking changes in the path resolving. Check the documentation of library to how migrate your alias paths.
Optional parameter alias path
// Old way
"GET user/:name?": "user.get"
// New way
"GET user{/:name}": "user.get"
Repeating parameter alias path
// Old way
"GET /users/*username": "user.resolveUsersByNames",
// New way
"GET /users/:username*": "user.resolveUsersByNames",
Using 0.15 new streaming solution
The [email protected] 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
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
:
{
// 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"
}
v0.10.7
What's Changed
- SSE Example with simple chat by @DonVietnam in #329
- fix: secure header assignment to avoid process crash by @furanzujin in #330
- Avoid stream hanging on error by @richardgarnier in #337
- imp(index.d.ts): correct export ts types by @0x0a0d in #338
- imp(index.d.ts): correct server type by @0x0a0d in #340
- fix: request url not logged correctly by @emiljanitzek in #341
- refactor: simplify http handler test with reusable setup functions by @emiljanitzek in #342
New Contributors
- @DonVietnam made their first contribution in #329
- @furanzujin made their first contribution in #330
- @richardgarnier made their first contribution in #337
- @emiljanitzek made their first contribution in #341
Full Changelog: v0.10.6...v0.10.7
v0.10.6
What's Changed
- update qs package to mitigate CVE-2022-24999 by @MichaelErmer in #320
- fix: correct types for route middleware functions by @andree-parakey in #327
- fix: incorrect key for calloptions type by @andree-parakey in #328
- feat: add support for qs options by @daniel-parakey in #326
New Contributors
- @MichaelErmer made their first contribution in #320
- @andree-parakey made their first contribution in #327
- @daniel-parakey made their first contribution in #326
Full Changelog: v0.10.5...v0.10.6
v0.10.5
What's Changed
- fix: #298: register on close and error event on response by @giovanni-bertoncelli in #299
- fix: resolve promise when close event is fired for res by @michelevincenzi in #301
- Update version number in changelog file by @HazemKhaled in #303
- Improve d.ts by @0x0a0d in #310
- add default reqTimeout by @AndreMaz in #312
- Improve rate limiter by @thib3113 in #317
- add
originalUrl
,parsedUrl
, andquery
to request typing by @OutdatedVersion in #304 - fix: add 201 Created to status codes by @mtiller in #297
New Contributors
- @giovanni-bertoncelli made their first contribution in #299
- @michelevincenzi made their first contribution in #301
- @HazemKhaled made their first contribution in #303
- @thib3113 made their first contribution in #317
- @mtiller made their first contribution in #297
Full Changelog: v0.10.4...v0.10.5
v0.10.4
What's Changed
- d.ts for v0.10.2 v0.10.3 by @0x0a0d in #280
- skip services without settings by @kechkibet in #283
- Fix to comment in multi-auth example by @machinaexdeo in #286
- Add alias as last parameter by @icebob in #290
- Fix cors problem in assets by @moonrailgun in #289
- Broadcast event after alias regeneration by @icebob in #292
New Contributors
- @kechkibet made their first contribution in #283
- @machinaexdeo made their first contribution in #286
- @moonrailgun made their first contribution in #289
Full Changelog: v0.10.3...v0.10.4
v0.10.3
Named authenticate & authorize methods #275
You can define custom authentication and authorization methods for every routes. In this case you should set the method name instead of true
value.
module.exports = {
mixins: ApiGatewayService,
settings: {
routes: [
{
path: "/aaa",
authentication: "aaaAuthn",
authorization: "aaaAuthz",
aliases: {
"GET hello": "test.hello"
}
},
{
path: "/bbb",
authentication: "bbbAuthn",
authorization: "bbbAuthz",
aliases: {
"GET hello": "test.hello"
}
},
{
path: "/ccc",
authentication: true,
authorization: true,
aliases: {
"GET hello": "test.hello"
}
}
]
},
methods: {
aaaAuthn() {
// ... do authn
},
aaaAuthz() {
// ... do authz
},
bbbAuthn() {
// ... do authn
},
bbbAuthz() {
// ... do authz
},
authenticate() {
// ... do authn
},
authorize() {
// ... do authz
}
}
}
Configure rate limit options in routes level
module.exports = {
name: 'api',
mixins: [ApiGateway],
settings: {
rateLimit: rateLimitGlobalConfig,
routes: [
{
path: '/withLocalRateLimit',
// now you can pass rateLimit here
// it will override the global rateLimit
rateLimit: rateLimitConfig,
aliases: {
'GET /2': 'test.2'
}
},
{
path: '/withGlobalRateLimit',
aliases: {
'GET /1': 'test.1'
}
}
]
}
}
Other changes
v0.10.2
Named routes
Many developers issued that version 0.10 doesn't support multiple routes with the same path. This version fixes it but you should give a unique name for the routes if they have same path.
Example
You can call /api/hi
without auth, but /api/hello
only with auth.
const ApiGateway = require("moleculer-web");
module.exports = {
mixins: [ApiGateway],
settings: {
path: "/api",
routes: [
{
name: "no-auth-route", // unique name
path: "/",
aliases: {
hi: "greeter.hello",
}
},
{
name: "with-auth-route", // unique name
path: "/",
aliases: {
"hello": "greeter.hello",
},
authorization: true
}
]
}
};
Changes
- add
removeRouteByName(name: string)
method to remove a route by its name.
v0.10.1
Changes
- set the default JSON bodyparser if
bodyParser: true
. #258 - add
pathToRegexpOptions
to route options to make available to pass options topath-to-regexp
library. #268 - add
debounceTime
to route options to make available to change the debounce time at service changes. #260 - new
errorHandler
method to allow developers to change the default error handling behaviour. #266 - fixes CORS preflight request handling in case of full-path aliases. #269
- update dependencies