All Versions
72
Latest Version
Avg Release Cycle
43 days
Latest Release
538 days ago

Changelog History
Page 3

  • v0.14.5 Changes

    March 25, 2020

    Wrapping service methods with middlewares

    ๐Ÿ†• New localMethod hook in middlewares which wraps the service methods.

    Example

    // my.middleware.js
    module.exports = {
        name: "MyMiddleware",
    
        localMethod(next, method) {
            return (...args) => {
                console.log(`The '${method.name}' method is called in '${method.service.fullName}' service.`, args);
                return handler(...args);
            }
        }
    }
    

    Schema for service methods

    Similar for action schema, you can define service methods with schema. It can be useful when middleware wraps service methods.

    Example for new method schema

    // posts.service.js
    module.exports = {
        name: "posts",
    
        methods: {
            list: {
                async handler(count) {
                    // Do something
                    return posts;
                }
            }
        }
    };
    

    ๐Ÿ”„ Changes

    • โž• add chunk limit for streams in message transporting. #683
    • โž• add baseUrl option to Datadog metric reporter. #694
    • ๐Ÿ›  fix open handles in unit tests. #695
    • โšก๏ธ update d.ts #699 #700 #703

  • v0.14.4 Changes

    March 08, 2020

    ๐Ÿ”„ Changes

    • โž• add maxSafeObjectSize to service broker options. Fixes #697
    • โž• add stop method to tracing exporters. Fixes #689
    • ๐Ÿ›  fix EventLegacy tracing exporter. Fixes #676
    • 0๏ธโƒฃ the defaultTags property in tracer options can be a Function, as well.

  • v0.14.3 Changes

    February 24, 2020

    ๐Ÿ”„ Changes

    • ๐Ÿ›  fix issue in AMQP 1.0 transporter

  • v0.14.2 Changes

    February 14, 2020

    ๐Ÿ‘Œ Support custom loggers

    If you have your custom logger you should wrap it into a Logger class and implement the getLogHandler method.

    Using a custom logger

    // moleculer.config.js
     const BaseLogger = require("moleculer").Loggers.Base;
    
    class MyLogger extends BaseLogger {
        getLogHandler(bindings) {
            return (type, args) => console[type](`[MYLOG-${bindings.mod}]`, ...args);
        }
    }
    
    module.exports = {
        logger: new MyLogger()
    };
    

  • v0.14.1 Changes

    February 12, 2020

    ๐Ÿ”„ Changes

    • ๐Ÿ›  fix bluebird import issue #674

  • v0.14.0 Changes

    February 12, 2020

    ๐ŸŽ‰ First 0.14 stable version. Full changelog: https://github.com/moleculerjs/moleculer/blob/master/CHANGELOG.md#0140-2020-02-12

    ๐Ÿ“„ Migration guide: https://github.com/moleculerjs/moleculer/blob/master/docs/MIGRATION_GUIDE_0.14.md

    ๐Ÿ”„ Changes since 0.14.0-rc2

    AMQP 1.0 transporter

    Thanks for @vladir95, AMQP 1.0 transporter is available.

    Please note, it is an experimental transporter. Do not use it in production yet!

    // moleculer.config.jsmodule.exports = { transporter: "amqp10://activemq-server:5672"};
    

    To use this transporter install the rhea-promise module with npm install rhea-promise --save command.

    Transporter options

    Options can be passed to rhea.connection.open() method, the topics, the queues, and the messages themselves.

    Connect to 'amqp10://guest:guest@localhost:5672'

    // moleculer.config.jsmodule.exports = { transporter: "AMQP10"};
    

    Connect to a remote server

    // moleculer.config.jsmodule.exports = { transporter: "amqp10://activemq-server:5672"};
    

    Connect to a remote server with options & credentials

    // moleculer.config.jsmodule.exports = { transporter: { url: "amqp10://user:pass@activemq-server:5672", eventTimeToLive: 5000, heartbeatTimeToLive: 5000, connectionOptions: { // rhea connection options https://github.com/amqp/rhea#connectoptions, example: ca: "", // (if using tls) servername: "", // (if using tls) key: "", // (if using tls with client auth) cert: "" // (if using tls with client auth) }, queueOptions: {}, // rhea queue options https://github.com/amqp/rhea#open\_receiveraddressoptions topicOptions: {}, // rhea queue options https://github.com/amqp/rhea#open\_receiveraddressoptions messageOptions: {}, // rhea message specific options https://github.com/amqp/rhea#message topicPrefix: "topic://", // RabbitMq uses '/topic/' instead, 'topic://' is more common prefetch: 1 } };
    

    Redis Cluster feature in Redis transporter

    Thanks for AAfraitane, use can connect to a Redis Cluster with the Redis transporter.

    Connect to Redis cluster

    // moleculer.config.jsmodule.exports = { transporter: { type: "Redis", options: { cluster: { nodes: [{ host: "localhost", port: 6379 }, { host: "localhost", port: 6378 }] } } } };
    
  • v0.14.0-rc2 Changes

    January 29, 2020

    ๐Ÿ”„ Changes

    • ๐Ÿ›  fix action hooks merging issue
  • v0.14.0-rc1 Changes

    January 26, 2020

    Minimum Node version is 10 (BREAKING)

    The Node version 8 LTS lifecycle has been ended on December 31, 2019, so the minimum required Node version is 10.

    Bluebird dropped (BREAKING)

    The Bluebird Promise library has been dropped from the project because as of Node 10 the native Promise implementation is faster (2x) than Bluebird.

    Nonetheless, you can use your desired Promise library, just set the Promise broker options.

    Using Bluebird

    const BluebirdPromise = require("bluebird");// moleculer.config.jsmodule.exports = { Promise: BluebirdPromise };
    

    โฑ > Please note, the given Promise library will be polyfilled with delay, method, timeout and mapSeries methods (which are used inside Moleculer core modules).

    ๐Ÿ‘ Better service event handler testing

    โœ… Service class has a new emitLocalEventHandler method in order to call a service event handler directly. It can be useful in Unit Tests because you don't need to emit an event with broker.emit.

    Example

    // posts.service.jsmodule.exports = { name: "posts", events: { async "user.created"(ctx) { this.myMethod(ctx.params); } } };
    
    // posts.service.spec.jsdescribe("Test events", () =\> { const broker = new ServiceBroker({ logger: false }); const svc = broker.createService(PostService); beforeAll(() =\> broker.start()); afterAll(() =\> broker.stop()); describe("Test 'user.created' event", () =\> { beforeAll(() =\> svc.myMethod = jest.fn()); afterAll(() =\> svc.myMethod.mockRestore()); it("should call the event handler", async () =\> { await svc.emitLocalEventHandler("branch.closed", { a: 5 }); expect(svc.myMethod).toBeCalledTimes(1); expect(svc.myMethod).toBeCalledWith({ a: 5 }); }); }); });
    

    ๐Ÿ‘ Stream objectMode support

    ๐Ÿ‘ Thanks for @artur-krueger, the request & response streams support objectMode, as well. You can also send Javascript objects via streams.

    Example

    Other changes

    • 0๏ธโƒฃ In metrics, the defaultBuckets value has been changed to milliseconds.
    • add caller label for EVENT_RECEIVED_TOTAL metric.
    • the heartbeat logic can be disabled by heartbeatInterval: 0 broker option.
    • โœ‚ remove the new currentContext property in Service & ServiceBroker.
    • in Service instances the original schema (before applying mixins) is available via this.originalSchema.
  • v0.14.0-beta7 Changes

    January 09, 2020

    Minimum Node version is 10

    The Node version 8 LTS lifecycle has been ended on December 31, 2019, so the minimum required Node version is 10.

    Event parameter validation

    ๐Ÿ‘ Similar to action parameter validation, the event parameter validation is supported.
    Like in action definition, you should define params in even definition and the built-in Validator validates the parameters in events.

    // mailer.service.jsmodule.exports = { name: "mailer", events: { "send.mail": { // Validation schema params: { from: "string|optional", to: "email", subject: "string" }, handler(ctx) { this.logger.info("Event received, parameters OK!", ctx.params); } } } };
    

    The validation errors are not sent back to the caller, they are logged or you can catch them with the new global error handler.

    ๐Ÿ›  Other fixes

  • v0.13.13 Changes

    February 11, 2020

    AMQP 1.0 transporter

    Thanks for @vladir95, AMQP 1.0 transporter is available.

    Please note, it is an experimental transporter. Do not use it in production yet!

    // moleculer.config.js
    module.exports = {
        transporter: "amqp10://activemq-server:5672"
    };
    

    To use this transporter install the rhea-promise module with npm install rhea-promise --save command.

    Transporter options

    Options can be passed to rhea.connection.open() method, the topics, the queues, and the messages themselves.

    Connect to 'amqp10://guest:guest@localhost:5672'

    // moleculer.config.js
    module.exports = {
        transporter: "AMQP10"
    };
    

    Connect to a remote server

    // moleculer.config.js
    module.exports = {
        transporter: "amqp10://activemq-server:5672"
    };
    

    Connect to a remote server with options & credentials

    // moleculer.config.js
    module.exports = {
        transporter: {
            url: "amqp10://user:pass@activemq-server:5672",
            eventTimeToLive: 5000,
            heartbeatTimeToLive: 5000,
            connectionOptions: { // rhea connection options https://github.com/amqp/rhea#connectoptions, example:
                ca: "", // (if using tls)
                servername: "", // (if using tls)
                key: "", // (if using tls with client auth)
                cert: "" // (if using tls with client auth)
            },
            queueOptions: {}, // rhea queue options https://github.com/amqp/rhea#open_receiveraddressoptions
            topicOptions: {}, // rhea queue options https://github.com/amqp/rhea#open_receiveraddressoptions
            messageOptions: {}, // rhea message specific options https://github.com/amqp/rhea#message
            topicPrefix: "topic://", // RabbitMq uses '/topic/' instead, 'topic://' is more common
            prefetch: 1
        }
    };
    

    Redis Cluster feature in Redis transporter

    Thanks for AAfraitane, use can connect to a Redis Cluster with the Redis transporter.

    Connect to Redis cluster

    // moleculer.config.js
    module.exports = {
        transporter: {
            type: "Redis",
            options: {
                cluster: {
                    nodes: [
                        { host: "localhost", port: 6379 },
                        { host: "localhost", port: 6378 }
                    ]
                }
            }
        }
    };