:rocket: Progressive microservices framework for Node.js

Overview

Moleculer logo

CI test Coverage Status Maintainability David Known Vulnerabilities Discord chat

Downloads FOSSA Status Patreon PayPal

Moleculer NPM version Twitter URL

Moleculer is a fast, modern and powerful microservices framework for Node.js. It helps you to build efficient, reliable & scalable services. Moleculer provides many features for building and managing your microservices.

Website: https://moleculer.services

Documentation: https://moleculer.services/docs

Top sponsors

What's included

  • Promise-based solution (async/await compatible)
  • request-reply concept
  • support event driven architecture with balancing
  • built-in service registry & dynamic service discovery
  • load balanced requests & events (round-robin, random, cpu-usage, latency, sharding)
  • many fault tolerance features (Circuit Breaker, Bulkhead, Retry, Timeout, Fallback)
  • plugin/middleware system
  • support versioned services
  • support Streams
  • service mixins
  • built-in caching solution (Memory, MemoryLRU, Redis)
  • pluggable loggers (Console, File, Pino, Bunyan, Winston, Debug, Datadog, Log4js)
  • pluggable transporters (TCP, NATS, MQTT, Redis, NATS Streaming, Kafka, AMQP 0.9, AMQP 1.0)
  • pluggable serializers (JSON, Avro, MsgPack, Protocol Buffer, Thrift)
  • pluggable parameter validator
  • multiple services on a node/server
  • master-less architecture, all nodes are equal
  • built-in parameter validation with fastest-validator
  • built-in metrics feature with reporters (Console, CSV, Datadog, Event, Prometheus, StatsD)
  • built-in tracing feature with exporters (Console, Datadog, Event, Jaeger, Zipkin, NewRelic)
  • official API gateway, Database access and many other modules...

Installation

$ npm i moleculer

or

$ yarn add moleculer

Create your first microservice

This example shows you how to create a small service with an add action which can add two numbers and how to call it.

const { ServiceBroker } = require("moleculer");

// Create a broker
const broker = new ServiceBroker();

// Create a service
broker.createService({
    name: "math",
    actions: {
        add(ctx) {
            return Number(ctx.params.a) + Number(ctx.params.b);
        }
    }
});

// Start broker
broker.start()
    // Call service
    .then(() => broker.call("math.add", { a: 5, b: 3 }))
    .then(res => console.log("5 + 3 =", res))
    .catch(err => console.error(`Error occurred! ${err.message}`));

Try it in your browser

Create a Moleculer project

Use the Moleculer CLI tool to create a new Moleculer based microservices project.

  1. Create a new project (named moleculer-demo)

    $ npx moleculer-cli -c moleculer init project moleculer-demo
  2. Open project folder

    $ cd moleculer-demo
  3. Start project

    $ npm run dev
  4. Open the http://localhost:3000/ link in your browser. It shows a welcome page which contains many information about your project & you can test the generated services.

🎉 Congratulations! Your first Moleculer-based microservices project is created. Read our documentation to learn more about Moleculer.

Welcome page

Official modules

We have many official modules for Moleculer. Check our list!

Supporting

Moleculer is an open source project. It is free to use for your personal or commercial projects. However, developing it takes up all our free time to make it better and better on a daily basis. If you like Moleculer framework, please support it.

Thank you very much!

For enterprise

Available as part of the Tidelift Subscription.

The maintainers of moleculer and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Documentation

You can find here the documentation.

Changelog

See CHANGELOG.md.

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Contributions

We welcome you to join to the development of Moleculer. Please read our contribution guide.

License

Moleculer is available under the MIT license.

3rd party licenses

Contact

Copyright (c) 2016-2021 MoleculerJS

@moleculerjs @MoleculerJS

Comments
  • AMQP Transporter

    AMQP Transporter

    Resolves #1

    This Transporter is a bit more involved than some of the others because it needs to treat some packet types specially. Broadcasted packets need to use AMQP exchanges, but targeted packets only need a queue.

This implementation also deals with Requests a bit differently than other Transporters do. Each action has its own work queue that multiple nodes can pull messages from. This means that messages are less likely to be lost (due to crashes / etc). Each node will consume more messages when it has an availability. The number of messages that can be handled concurrently by a node can be specified with the amqp.prefetch option.

    Requests and Responses don’t have a set time-to-live, but all other packet types do. Currently events’ time-to-live can be configured using the amqp.eventTimeToLive option, but the other types are hardcoded at 5 seconds.

    Transporter Options:

    new AmqpTransporter({
      amqp: {
        url: "amqp://guest:guest@localhost:5672",
        eventTimeToLive: 5000,
        prefetch: 1
  
      }
    });
    

    AMQP Transport behaviour by topic

    AMQP Transporter diagram

    I’ve included unit tests and some integration tests. The integration tests are skipped right now because they require an amqp server to be running at amqp://guest:guest@localhost:5672. Let me know if I should remove them. :+1:


    Other notes:

    • I don’t have a ton of experience with JSDoc, don’t hesitate to let me know if I can improve them.
    • I tried to to use istanbul ignore the same way as in other files, but let me know if I should change anything.

    Status: In Progress Type: Enhancement Module: Transporter 
    opened by Nathan-Schwartz 51
  • Protocol discussions for moleculer-go

    Protocol discussions for moleculer-go

    hi, I'm trying to implement moleculer-go version library . I'm a little confused by HEARTBEAT and PING/PONG. Since HEARTBEAT already take 5s/15s mark disconnect node as "broken", why still need PING/PONG ?

    Is PING/PONG used for upper application layer , HEARTBEAT is designed for internal usage ?

    Type: Question 
    opened by roytan883 45
  • metrics make request 10x times slower

    metrics make request 10x times slower

    The issue scenario is : apiGateway.rest -> auth.authorize->demo.welcome->demo.hello every step is very simple, should only consider network cost.

    If i enable metrics: true in each services process, use about 120ms total. Buf if i disable metrics, it only use about 10ms.

    metrics internal use event broadcast ? Then is should not impact normal performance so badly.

    Module: Core Status: Need reproduce 
    opened by roytan883 39
  • AMQP 1.0 Transporter

    AMQP 1.0 Transporter

    :memo: Description

    Added moleculer transporter for AMQP 1.0 protocol.

    :dart: Relevant issues

    #561

    :gem: Type of change

    • [X] This change requires a documentation update
    • [X] New feature (non-breaking change which adds functionality)

    :scroll: Example code

    	const broker = new ServiceBroker({
    		nodeID: "node",
    		logger: false,
    		transporter: "amqp10://admin:admin@localhost:5672"
    	});
    

    :vertical_traffic_light: How Has This Been Tested?

    Tested with moleculer 0.13.11 against ActiveMQ broker 5.15.10

    • [X] Unit Tests
    • [X] Flow Tests
    • [X] Some load tests

    :checkered_flag: Checklist:

    • [X] My code follows the style guidelines of this project
    • [X] I have performed a self-review of my own code
    • [X] I have added tests that prove my fix is effective or that my feature works
    • [X] New and existing unit tests pass locally with my changes
    • [X] I have commented my code, particularly in hard-to-understand areas
    opened by xvld 35
  • Enable zero-configuration/decentralized networking like 'Cote'

    Enable zero-configuration/decentralized networking like 'Cote'

    It's a pretty big win if moleculer could also work like this: http://cote.js.org/#multicast-address

    The single point of failture like NATS would be gone.

    Priority: Low Status: In Progress Type: Enhancement Module: Transporter 
    opened by demetriusnunes 32
  • Improve AMQP Integration Tests

    Improve AMQP Integration Tests

    Changes

    • Remove legacy amqp tests
    • Add important test cases for RPC
    • Enhance purge function to allow clearing queues without deleting. Clears queues between tests and deletes queues and exchanges before and after suites.
    • Fix type error in AMQP Transporter
    • Run the same test suite for built-in and AMQP balancing
    • preferLocal = false for RPC suite
    • Run AMQP integration tests serially to prevent unexpected states

    @icebob let me know if you any questions or concerns 👍

    opened by Nathan-Schwartz 29
  • Official Typescript project template

    Official Typescript project template

    Describe the solution you'd like Would be good an official project template with Typescript. I have not enough experience to create it. Can somebody help me with it?

    Base template: https://github.com/moleculerjs/moleculer-template-project

    Thank you!

    Type: Enhancement help wanted 
    opened by icebob 27
  • NATS server disconnecting randomly

    NATS server disconnecting randomly

    Prerequisites

    Please answer the following questions for yourself before submitting an issue.

    • [x] I am running the 0.13.11 version
    • [x] I checked the documentation and found no answer
    • [x] I checked to make sure that this issue has not already been filed
    • [x] I'm reporting the issue to the correct repository (May be it belongs to NATS repository I don't know)

    Current Behavior

    Im using the transporter NATS option by keeping the config as transporter: "NATS", But while coding in vscode and hotreloading sometimes NATS server is disconnecting and saying the error as Invalid subject, but again changing the some code and hot reloading it is reconnecting successfully. Actually this can be ok in development , but we are using docker deployment there is no option for hot-reloading option so that NATS can reconnect again.

    Expected Behavior

    While coding and hot reloading the NATS server should stay connected always.

    Failure Information

    Please check the image for more error info nats

    Steps to Reproduce

    Please provide detailed steps for reproducing the issue.

    1. init project with moleculer cli
    2. added 2 or more services
    3. Use NATS as transporter
    4. Try to change code and do hot-reloads

    Context

    Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

    • Moleculer version:0.13.11
    • NodeJS version: 8.12.0
    • Operating System: Ubuntu 19.04
    Module: Transporter Status: Need reproduce 
    opened by knvpk 24
  • Typescript: ThisType in ActionHandler is not work

    Typescript: ThisType in ActionHandler is not work

    Prerequisites

    Please answer the following questions for yourself before submitting an issue.

    • [x] I am running the latest version
    • [x] I checked the documentation and found no answer
    • [x] I checked to make sure that this issue has not already been filed
    • [x] I'm reporting the issue to the correct repository

    Current Behavior

    For example code below:

        this.parseServiceSchema({
          name: 'user',
          mixins: [DbService],
          actions: {
            login: {
              rest: 'POST /login',
              async handler(ctx: Context) {
                return {
                  id: 1,
                  username: 'test',
                };
              },
            },
          },
        });
    

    I try to typing this. and not any type suggest display.

    When i try to check the type of this, just any.

    Expected Behavior

    Maybe we should change

    type ActionHandler<T = any> = ((ctx: Context<any, any>) => Promise<T> | T) & ThisType<Service>;
    

    to

    type ActionHandler<T = any> = ((this: Service, ctx: Context<any, any>) => Promise<T> | T);
    

    ThisType looks like use in parent, not in ActionHandler self

    https://github.com/moleculerjs/moleculer/blob/7b94f7cac722f5f82a1b5ed8906a915fa586b79f/index.d.ts#L47

    opened by moonrailgun 22
  • A way to destructure services into individual Docker images

    A way to destructure services into individual Docker images

    Is your feature request related to a problem? Please describe. Building Docker images is a problem. As of now, we have github repos for each service. So we can build docker images individually.

    Describe the solution you'd like However, we'd like a way for moleculer to be able to destructure the services folder into separate docker builds.

    Describe alternatives you've considered We're currently working on a repo/service structure, which is not very efficient.

    Type: Discussion 
    opened by amroessam 22
  • Private services

    Private services

    If a service has a $private: true setting, the service actions can't be called from remote services (only from local services)

    module.exports = {
        name: "invoices",
        settings: {
            $private: true
        }	
        actions: {
            create() {}
        }
    }
    
    Status: Proposal Type: Enhancement Module: Core 
    opened by icebob 22
  • Improves StartedStoppedHandler definition to return Promise with void[]

    Improves StartedStoppedHandler definition to return Promise with void[]

    When using TypeScript, the started, created and stopped methods in services (and for extension, middleware) are supposed to be able to return any kind of Promise, but the current type definition breaks in case a Promise.all is returned. This PR fixes it by adding a Promise<void[]> return type.

    • [x] Bug fix (non-breaking change which fixes an issue)

    :vertical_traffic_light: How Has This Been Tested?

    Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

    • [x] Applied the change to index.d.ts and then checked type definition in a middleware (extending ServiceSchema). Linter did not return any error while testing created() {return Promise.all(promises)}.

    :checkered_flag: Checklist:

    • [x] My code follows the style guidelines of this project
    • [x] I have performed a self-review of my own code
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [x] New and existing unit tests pass locally with my changes
    opened by danieledraganti 0
  • fix for #1169: getPrototypeOf instead of __proto__

    fix for #1169: getPrototypeOf instead of __proto__

    :memo: Description

    This PR basically replaces __proto__ with Object.getPrototypeOf.

    :dart: Relevant issues

    This PR is related to issue #1169.

    :gem: Type of change

    • [X] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
    • [ ] This change requires a documentation update

    :scroll: Example code

    NodeJS flag --disable-proto can now be used:

    node --disable-proto=delete index.js
    

    :vertical_traffic_light: How Has This Been Tested?

    The whole test plan is executed with --disable-proto=delete passed to NodeJS.

    :checkered_flag: Checklist:

    • [X] My code follows the style guidelines of this project
    • [X] I have performed a self-review of my own code
    • [X] I have added tests that prove my fix is effective or that my feature works
    • [X] New and existing unit tests pass locally with my changes
    • [X] I have commented my code, particularly in hard-to-understand areas
    Module: Core 
    opened by gautaz 1
  • Use of __proto__ seems discouraged

    Use of __proto__ seems discouraged

    Prerequisites

    • [X] I am running the latest version
    • [X] I checked the documentation and found no answer
    • [X] I checked to make sure that this issue has not already been filed
    • [X] I'm reporting the issue to the correct repository

    Current Behavior

    Looking at https://github.com/moleculerjs/moleculer/blob/3e8fcef78e485888c012086535b93aae9f5d3542/src/service-broker.js#L1777-L1785 It seems that the ServiceBroker code relies on __proto__ which seems to be discouraged from a security point of view.

    __proto__ is even unavailable on deno, see https://github.com/denoland/deno/issues/4324. This means that moleculer currently cannot be used with node --disable-proto=delete or deno even with the latest addition of npm specifiers.

    Expected Behavior

    The expectation is that moleculer runs with the --disable-proto flag provided by node or even deno with npm specifiers.

    Failure Information

    Currently with node --disable-proto=delete, the Moleculer microservice sample fails with:

    [2022-12-19T10:43:07.628Z] FATAL nixos-37367/BROKER: Unable to create ServiceBroker. TypeError: Cannot read properties of undefined (reading 'prototype')
        at Object.getConstructorName (XXX/node-test/node_modules/moleculer/src/utils.js:477:20)
        at ServiceBroker.normalizeSchemaConstructor (XXX/node-test/node_modules/moleculer/src/service-broker.js:1778:18)
        at ServiceBroker.createService (XXX/node-test/node_modules/moleculer/src/service-broker.js:830:17)
        at ServiceBroker.registerInternalServices (XXX/node-test/node_modules/moleculer/src/service-broker.js:978:8)
        at new ServiceBroker (XXX/node-test/node_modules/moleculer/src/service-broker.js:312:10)
        at file:///XXX/node-test/index.js:4:16
        at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
        at async Promise.all (index 0)
        at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
        at async loadESM (node:internal/process/esm_loader:88:5)
    

    With deno:

    [2022-12-19T10:07:06.801Z] FATAL nixos-36342/BROKER: Unable to create ServiceBroker. TypeError: Cannot read properties of undefined (reading 'prototype')
        at Object.getConstructorName (file:///XXX/.cache/deno/npm/registry.npmjs.org/moleculer/0.14.27/src/utils.js:477:20)
        at ServiceBroker.normalizeSchemaConstructor (file:///XXX/.cache/deno/npm/registry.npmjs.org/moleculer/0.14.27/src/service-broker.js:1780:18)
        at ServiceBroker.createService (file:///XXX/.cache/deno/npm/registry.npmjs.org/moleculer/0.14.27/src/service-broker.js:830:17)
        at ServiceBroker.registerInternalServices (file:///XXX/.cache/deno/npm/registry.npmjs.org/moleculer/0.14.27/src/service-broker.js:978:8)
        at new ServiceBroker (file:///XXX/.cache/deno/npm/registry.npmjs.org/moleculer/0.14.27/src/service-broker.js:312:10)
        at file:///XXX/deno-test/index.js:4:16
    

    Steps to Reproduce

    Please provide detailed steps for reproducing the issue.

    1. Initialize a project with the Moleculer microservice sample
    2. Run the sample with node --disable-proto=delete or deno

    Reproduce code snippet

    See the Moleculer microservice sample.

    Context

    Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

    • Moleculer version: 0.14.27
    • NodeJS version: v16.16.0
    • Operating System: NixOS 22.11

    Failure Logs

    See Failure Information.

    opened by gautaz 2
  • feat(types): add middlewares types

    feat(types): add middlewares types

    Add typing for the optionals middlewares

    PS : I typed the encryption middleware too, but I think it's not a good middleware, not secure (IV not changing), and hard to use (password length need to be a strict length)

    :gem: Type of change

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [X] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
    • [ ] This change requires a documentation update

    :checkered_flag: Checklist:

    • [X] My code follows the style guidelines of this project
    • [X] I have performed a self-review of my own code
    • [X] I have added tests that prove my fix is effective or that my feature works
    • [X] New and existing unit tests pass locally with my changes
    • [X] I have commented my code, particularly in hard-to-understand areas
    opened by thib3113 2
  • Getting **Parsing failed at** error while calling garphql mutation for upload image

    Getting **Parsing failed at** error while calling garphql mutation for upload image

    While calling Garphql mutation for upload image getting parsing failed error attach code and error screenshots for your references.

    My code image

    In api.service.js setting of bodyParsers image

    Error I am getting image

    Please help me how can I resolve this error this same code run smoothly in ExpressJs

    opened by amitpatel9169 2
Releases(v0.14.27)
  • v0.14.27(Dec 17, 2022)

    What's Changed

    • feat(TS/cachers): add types for lock functions by @thib3113 in https://github.com/moleculerjs/moleculer/pull/1152
    • Typing add spanName and safeTags to tracing options by @thib3113 in https://github.com/moleculerjs/moleculer/pull/1157
    • Use interface instead of type to allow for declaration merging by @shawnmcknight in https://github.com/moleculerjs/moleculer/pull/1165
    • Prevent registerInternalServices deprecation warning by @DenisFerrero in https://github.com/moleculerjs/moleculer/pull/1163

    New Contributors

    • @DenisFerrero made their first contribution in https://github.com/moleculerjs/moleculer/pull/1163

    Full Changelog: https://github.com/moleculerjs/moleculer/compare/v0.14.26...v0.14.27

    Source code(tar.gz)
    Source code(zip)
  • v0.14.26(Nov 10, 2022)

    What's Changed

    Changes

    • fix typescript definitions for the Service class #1139
    • allow matching hooks to multiple actions with "|" #1149
    • fix serializers datetime flaky test #1151

    New Contributors

    • @sabadoryo made their first contribution in https://github.com/moleculerjs/moleculer/pull/1148
    • @SKarajic made their first contribution in https://github.com/moleculerjs/moleculer/pull/1139
    • @someone635 made their first contribution in https://github.com/moleculerjs/moleculer/pull/1149
    • @sorattorafa made their first contribution in https://github.com/moleculerjs/moleculer/pull/1151

    Full Changelog: https://github.com/moleculerjs/moleculer/compare/v0.14.25...v0.14.26

    Source code(tar.gz)
    Source code(zip)
  • v0.14.25(Oct 29, 2022)

  • v0.14.24(Oct 11, 2022)

    Changes

    • allow moleculer-runner to resolve configuration files from node_modules #1126
    • fixed slower broker startup time issue #1132
    • fixed memory leak at dynamic service creation #1121
    • fixed invalid 'undefined' type in validator schema. #1137
    • update dependencies
    Source code(tar.gz)
    Source code(zip)
  • v0.14.23(Aug 16, 2022)

  • v0.14.22(Aug 13, 2022)

    35 commits from 11 contributors.

    Changes

    • fixed 'Ctx is undefined when using shard strategy and preferLocal is false, throws error on emit' #1072
    • fixed info packet send at broker stop #1101
    • added support for either-or versions to waitForServices #1030
    • fixed streaming issue with compression #1100
    • add requestID to debug logs in transit #1104
    • removed static on methods for the use of ServiceFactory #1098
    • fixed the issue with setting tracing and metrics options with env variables #1112
    • added dependencyTimeout broker option #1118
    • improved d.ts #1099 #1111 #1115
    • updated dependencies
    Source code(tar.gz)
    Source code(zip)
  • v0.14.21(Apr 30, 2022)

    20 commits from 2 contributors.

    ESM support #1063

    This version contains an ESM-based Moleculer Runner. This Runner is able to load ESM configuration file and ESM services. It can load the CJS services, as well

    Example usage

    moleculer-runner-esm --repl services/**/*.service.mjs
    

    Moreover, the index.js file is wrapped into index.mjs, so you can import internal modules from the core in ESM modules. E.g.:

    import { ServiceBroker, Errors } from "moleculer";
    

    Please note, the hot-reload function doesn't work with this ESM Runner. The cause: https://github.com/nodejs/modules/issues/307 Node maintainers try to solve the missing features (module cache and module dependency tree) with loaders but this API is not stable yet.

    Other Changes

    • broker.stopping property is created to indicate that broker is in stopping state.
    Source code(tar.gz)
    Source code(zip)
  • v0.14.20(Apr 19, 2022)

    52 commits from 8 contributors.

    Dependency logic changed #1077

    In mixed architecture, it's not hard to create a circular service dependency that may cause a dead-lock during the start of Moleculer nodes. The problem is that Moleculer node only sends the local service registry to remote nodes after all local services started properly. As of 0.14.20, this behavior has changed. The new logic uses a debounced registry sending method which is triggered every time a local service, that the node manages, has started().
    Note that the new method generates more INFO packets, than early versions, during the start of the node. The number of INFO packets depends on the number of the services that the node manages. The debounce timeout, between sending INFO packets, is 1 second.

    Other Changes

    • fix ActionLogger and TransitLogger middlewares.
    • update Datadog Logger using v2 API. #1056
    • update dependencies.
    • update d.ts file. #1064, #1073
    • fix pino child logger bindings. #1075
    Source code(tar.gz)
    Source code(zip)
  • v0.14.19(Jan 8, 2022)

    69 commits from 7 contributors.

    Custom error recreation feature #1017

    You can create a custom Regenerator class which is able to serialize and deserialize your custom errors. It's necessary when the custom error is created on a remote node and must be serialized to be able to sent back to the caller.

    Create a custom Regenerator

    const { Regenerator, MoleculerError } = require("moleculer").Errors;
    
    class TimestampedError extends MoleculerError {
        constructor(message, code, type, data, timestamp) {
            super(message, code, type, data);
            this.timestamp = timestamp;
        }
    }
    
    class CustomRegenerator extends Regenerator {
        restoreCustomError(plainError, payload) {
            const { name, message, code, type, data, timestamp } = plainError;
            switch (name) {
                case "TimestampedError":
                    return new TimestampedError(message, code, type, data, timestamp);
            }
        }
        extractPlainError(err) {
            return {
                ...super.extractPlainError(err),
                timestamp: err.timestamp
            };
        }
    }
    module.exports = CustomRegenerator;
    

    Use it in broker options

    // moleculer.config.js
    const CustomRegenerator = require("./custom-regenerator");
    module.exports = {
        errorRegenerator: new CustomRegenerator()
    }
    

    Error events #1048

    When an error occured inside ServiceBroker, it's printed to the console, but there was no option that you can process it programatically (e.g. transfer to an external monitoring service). This feature solves it. Every error inside ServiceBroker broadcasts a local (not transported) event ($transporter.error, $broker.error, $transit.error, $cacher.error, $discoverer.error) what you can listen in your dedicated service or in a middleware.

    Example to listen in an error-tracker service

    module.exports = {
        name: "error-tracker",
    
        events: {
            "$**.error": {
                handler(ctx) {
                    // Send the error to the tracker
                    this.sendError(ctx.params.error);
                }
            }
        }
    }
    

    Example to listen in a middleware or in broker options

    module.exports = {
        created(broker) {
            broker.localBus.on("*.error", payload => {
                // Send the error to the tracker
                this.sendError(payload.error);
            });
        }
    }
    

    Wildcards in Action Hooks #1051

    You can use * wildcard in action names when you use it in Action Hooks.

    Example

    hooks: {
        before: {
            // Applies to all actions that start with "create-"
            "create-*": [],
            
            // Applies to all actions that end with "-user"
            "*-user": [],
        }
    }
    

    Other Changes

    • update dependencies.
    • update d.ts file. #1025, #1028, #1032
    • add safetyTags option to tracing exporters. #1052
    Source code(tar.gz)
    Source code(zip)
  • v0.14.18(Oct 20, 2021)

  • v0.14.17(Sep 13, 2021)

    61 commits from 10 contributors.

    Changes

    • reformat codebase with Prettier.
    • fix binding issue in Pino logger. #974
    • update d.ts file. #980 #970
    • transit message handler promises are resolved. #984
    • fix cacher issue if cacher is not connected. #987
    • fix Jest open handlers issue. #989
    • fix cacher cloning issue. #990
    • add custom headers option to Zipkin trace exporter. #993
    • fix heartbeatTimeout option in BaseDiscoverer. #985
    • add cacher keygen option action definition. #1004
    • update dependencies
    Source code(tar.gz)
    Source code(zip)
  • v0.14.16(Jul 21, 2021)

    11 commits from 4 contributors.

    Changes

    • fix nats-streaming version in peerDependencies.
    • RedisCacher pingInterval option. #961
    • Update NATS transporter messages to debug. #963
    • update d.ts file. #964 #966
    • update dependencies
    Source code(tar.gz)
    Source code(zip)
  • v0.14.15(Jul 10, 2021)

    15 commits from 5 contributors.

    Changes

    • fix nats version in peerDependencies.
    • convert url to servers in nats@2. #954
    • add typing for mcall settled option. #957
    • revert TS ThisType issue in 0.14.14. #958
    • update dependencies
    • add useTag259ForMaps: false default option for CBOR serializer to keep the compatibility.
    Source code(tar.gz)
    Source code(zip)
  • v0.14.14(Jun 27, 2021)

    105 commits from 11 contributors.

    New CBOR serializer #905

    CBOR (cbor-x) is a new serializer but faster than any other serializers.

    Example

    // moleculer.config.js
    module.exports = {
        logger: true,
        serializer: "CBOR"
    };
    

    Benchmark

    Suite: Serialize packet with 10bytes
    √ JSON               509,217 rps
    √ Avro               308,711 rps
    √ MsgPack             79,932 rps
    √ ProtoBuf           435,183 rps
    √ Thrift              93,324 rps
    √ Notepack           530,121 rps
    √ CBOR             1,016,135 rps
    
       JSON (#)            0%        (509,217 rps)   (avg: 1μs)
       Avro           -39.38%        (308,711 rps)   (avg: 3μs)
       MsgPack         -84.3%         (79,932 rps)   (avg: 12μs)
       ProtoBuf       -14.54%        (435,183 rps)   (avg: 2μs)
       Thrift         -81.67%         (93,324 rps)   (avg: 10μs)
       Notepack        +4.11%        (530,121 rps)   (avg: 1μs)
       CBOR           +99.55%      (1,016,135 rps)   (avg: 984ns)
    

    settled option in broker.mcall

    The broker.mcall method has a new settled option to receive all Promise results. Without this option, if you make a multi-call and one call is rejected, the response will be a rejected Promise and you don't know how many (and which) calls were rejected.

    If settled: true, the method returns a resolved Promise in any case and the response contains the statuses and responses of all calls.

    Example

    const res = await broker.mcall([
        { action: "posts.find", params: { limit: 2, offset: 0 },
        { action: "users.find", params: { limit: 2, sort: "username" } },
        { action: "service.notfound", params: { notfound: 1 } }
    ], { settled: true });
    console.log(res);
    

    The res will be something similar to

    [
        { status: "fulfilled", value: [/*... response of `posts.find`...*/] },
        { status: "fulfilled", value: [/*... response of `users.find`...*/] },
        { status: "rejected", reason: {/*... Rejected response/Error`...*/} }
    ]
    

    New MOLECULER_CONFIG environment variable in Runner

    In the Moleculer Runner, you can configure the configuration filename and path with the MOLECULER_CONFIG environment variable. It means, no need to specify the config file with --config argument.

    Supporting [email protected] in NATS transporter

    The new nats 2.x.x version has a new breaking API which has locked the NATS transporter for [email protected] library. As of this release, the NATS transporter supports both major versions of the nats library.

    The transporter automatically detects the version of the library and uses the correct API.

    Async custom validator functions and ctx as metadata

    Since [email protected], the FastestValidator supports async custom validators and you can pass metadata for custom validator functions. In Moleculer, the FastestValidator passes the ctx as metadata. It means you can access to the current context, service, broker and you can make async calls (e.g calling another service) in custom checker functions.

    Example

    // posts.service.js
    module.exports = {
        name: "posts",
        actions: {
            params: {
                $$async: true,
                owner: { type: "string", custom: async (value, errors, schema, name, parent, context) => {
                    const ctx = context.meta;
    
                    const res = await ctx.call("users.isValid", { id: value });
                    if (res !== true)
                        errors.push({ type: "invalidOwner", field: "owner", actual: value });
                    return value;
                } }, 
            },
            /* ... */
        }
    }
    

    Changes

    • fix node crash in encryption mode with TCP transporter. #849
    • expose Utils in typescript definition. #909
    • other d.ts improvements. #920, #922, #934, #950
    • fix etcd3 discoverer lease-loss issue #922
    • catch errors in Compression and Encryption middlewares. #850
    • using optional peer dependencies. #911
    • add relevant packet to to serialization and deserialization calls. #932
    • fix disabled balancer issue with external discoverer. #933
    Source code(tar.gz)
    Source code(zip)
  • v0.14.13(Apr 9, 2021)

    Changes (62 commits from 12 contributors)

    • update dependencies
    • logging if encryption middleware can't decrypt the data instead of crashing. #853
    • fix disableHeartbeatChecks option handling. #858
    • force scanning only master redis nodes for deletion. #865
    • add more info into waitForServices debug log messages. #870
    • fix EVENT packet Avro schema. #856
    • fix array & date conversion in cacher default key generator. #883
    • fix Datadog tracing exporter. #890
    • better elapsed time handling in tracing. #899
    • improve type definitions. #843, #885, #886
    • add E2E tests for CI (test all built-in transporter & serializers)
    Source code(tar.gz)
    Source code(zip)
  • v0.14.12(Jan 3, 2021)

    Other changes

    • update dependencies
    • improved type definitions. #816 #817 #834 #840
    • support rediss:// cacher URI. #837
    • fix Event Trace exporter generated events loop. #836
    • change log level of node disconnected message. #838
    • improve the broker.waitForServices response. #843
    • fix recursive hot-reload issue on Linux OS. #848
    Source code(tar.gz)
    Source code(zip)
  • v0.14.11(Sep 27, 2020)

    New merged service lifecycle hook

    Service has a new merged lifecycle hook which is called after the service schemas (including mixins) has been merged but before service is registered. It means you can manipulate the merged service schema before it's processed.

    Example

    // posts.service.js
    module.exports = {
        name: "posts",
    
        settings: {},
    
        actions: {
            find: {
                params: {
                    limit: "number"
                }
                handler(ctx) {
                    // ...
                }
            }
        },
    
        merged(schema) {
            // Modify the service settings
            schema.settings.myProp = "myValue";
            // Modify the param validation schema in an action schema
            schema.actions.find.params.offset = "number";
        }
    };
    

    Other changes

    • add requestID tag to all action and event spans #802
    • fix bug in second level of mixins with $secureSettings #811
    Source code(tar.gz)
    Source code(zip)
  • v0.14.10(Aug 23, 2020)

  • v0.14.9(Aug 6, 2020)

    Register method in module resolver

    If you create a custom module (e.g. serializer), you can register it into the built-in modules with the register method. This method is also available in all other built-in module resolver.

    Example

    // SafeJsonSerializer.js
    const { Serializers } = require("moleculer");
    
    class SafeJsonSerializer {}
    
    Serializers.register("SafeJSON", SafeJSON);
    
    module.exports = SafeJsonSerializer;
    
    // moleculer.config.js
    require("./SafeJsonSerializer");
    
    module.exports = {
        nodeID: "node-100",
        serializer: "SafeJSON"
        // ...
    });
    

    Changeable validation property name

    You can change the params property name in validator options. It can be useful if you have a custom Validator implementation.

    const broker = new ServiceBroker({
        validator: {
            type: "Fastest",
            options: {
                paramName: "myParams" // using `myParams` instead of `params`
            }
        }
    });
    
    broker.createService({
        name: "posts",
        actions: {
            create: {
                myParams: {
                    title: "string"
                }
            },
            handler(ctx) { /* ... */ }
        }
    });
    

    Global tracing span tags for actions & events

    Thanks for @kthompson23, you can configure the action & events tracing span tags globally. These tags will be used for all actions & events where tracing is enabled. Of course, you can overwrite them locally in the action & event schema.

    Example

    // moleculer.config.js
    module.exports = {
        tracing: {
            enabled: true,
            exporter: 'Zipkin',
            tags: {
                action: {
                    meta: ['app.id', 'user.email', 'workspace.name'],
                    params: false,  // overrides default behavior of all params being adding as tags
                    response: true,
                },
                event: (ctx) {
                    return {
                        caller: ctx.caller,
                    }
                }  
            }
        }
    }
    

    Other changes

    • fix multiple trace spans with same ID issue in case of retries.
    • update dependencies
    • add lastValue property to histogram metric type.
    • update return type of context's copy method.
    • add configuration hotReloadModules #779
    • Remove Zipkin v1 annotations and change kind to SERVER
    Source code(tar.gz)
    Source code(zip)
  • v0.14.8(Jun 27, 2020)

    Github Sponsoring is available for Moleculer :tada:

    We have been approved in Github Sponsors program, so you can sponsor the Moleculer project via Github Sponsors. If you have taxing problem with Patreon, change to Github Sponsors.

    New Validator configuration

    The validator has the same module configuration in broker options like other modules. It means you can configure the validation constructor options via broker options (moleculer.config.js).

    Default usage:

    //moleculer.config.js
    module.exports = {
        nodeID: "node-100",
        validator: true // Using the default Fastest Validator
    }
    

    Using built-in validator name:

    //moleculer.config.js
    module.exports = {
        nodeID: "node-100",
        validator: "FastestValidator" // Using the Fastest Validator
    }
    

    Example with options:

    //moleculer.config.js
    module.exports = {
        nodeID: "node-100",
        validator: {
            type: "FastestValidator",
            options: {
                useNewCustomCheckerFunction: true,
                defaults: { /*...*/ },
                messages: { /*...*/ },
                aliases: { /*...*/ }
            }
        }
    }
    

    Example with custom validator

    //moleculer.config.js
    const BaseValidator = require("moleculer").Validators.Base;
    
    class MyValidator extends BaseValidator {}
    
    module.exports = {
        nodeID: "node-100",
        validator: new MyValidator()
    }
    

    New metrics

    Added the following new metrics:

    • moleculer.event.received.active: Number of active event executions.
    • moleculer.event.received.error.total: Number of event execution errors.
    • moleculer.event.received.time: Execution time of events in milliseconds.
    • os.memory.total: OS used memory size.

    Other changes

    • support using moleculer.config.js with export default.
    • remove some lodash methods.
    • upgrade to the latest tsd.
    • new dependencyInterval broker option. Using as default value for broker.waitForServices #761
    • fix Datadog traceID, spanID generation logic to work with latest dd-trace.
    • add error stack trace to EventLegacy trace exporter.
    • fix INFO key issue in Redis Discoverer after Redis server restarting.
    Source code(tar.gz)
    Source code(zip)
  • v0.14.7(May 22, 2020)

    New Discoverer module

    The Discoverer is a new built-in module in Moleculer framework. It's responsible for that all Moleculer nodes can discover each other and check them with heartbeats. In previous versions, it was an integrated module inside ServiceRegistry & Transit modules. In this version, the discovery logic has been extracted to a separated built-in module. It means you can replace it to other built-in implementations or a custom one. The current discovery & heartbeat logic is moved to the Local Discoverer.

    Nevertheless, this version also contains other discoverers, like Redis & etcd3 discoverers. Both of them require an external server to make them work. One of the main advantages of the external discoverers, the node discovery & heartbeat packets don't overload the communication on the transporter. The transporter transfers only the request, response, event packets. By the way, the external discoverers have some disadvantages, as well. These discoverers can detect lazier the new and disconnected nodes because they scan the heartbeat keys periodically on the remote Redis/etcd3 server. The period of checks depends on the heartbeatInterval broker option.

    The Local Discoverer (which is the default) works like the discovery of previous versions, so if you want to keep the original logic, you'll have to do nothing.

    Please note the TCP transporter uses Gossip protocol & UDP packets for discovery & heartbeats, it means it can work only with Local Discoverer.

    Local Discoverer

    It's the default Discoverer, it uses the transporter module to discover all other moleculer nodes. It's quick and fast but if you have too many nodes (>100), the nodes can generate a lot of heartbeat packets which can reduce the performance of request/response packets.

    Example

    // moleculer.config.js
    module.exports = {
        registry: {
            discoverer: "Local"
        }    
    }
    

    Example with options

    // moleculer.config.js
    module.exports = {
        registry: {
            discoverer: {
                type: "Local",
                options: {
                    // Send heartbeat in every 10 seconds
                    heartbeatInterval: 10,
    
                    // Heartbeat timeout in seconds
                    heartbeatTimeout: 30,
    
                    // Disable heartbeat checking & sending, if true
                    disableHeartbeatChecks: false,
    
                    // Disable removing offline nodes from registry, if true
                    disableOfflineNodeRemoving: false,
    
                    // Remove offline nodes after 10 minutes
                    cleanOfflineNodesTimeout: 10 * 60
                }
            }
        }    
    }
    

    Redis Discoverer

    This is an experimental module. Do not use it in production yet!

    This Discoverer uses a Redis server to discover Moleculer nodes. The heartbeat & discovery packets are stored in Redis keys. Thanks to Redis key expiration, if a node crashed or disconnected unexpectedly, the Redis will remove its heartbeat keys from the server and other nodes can detect it.

    Example to connect local Redis server

    // moleculer.config.js
    module.exports = {
        registry: {
            discoverer: "Redis"
        }    
    }
    

    Example to connect remote Redis server

    // moleculer.config.js
    module.exports = {
        registry: {
            discoverer: "redis://redis-server:6379"
        }    
    }
    

    Example with options

    // moleculer.config.js
    module.exports = {
        registry: {
            discoverer: {
                type: "Redis",
                options: {
                    redis: {
                        // Redis connection options.
                        // More info: https://github.com/luin/ioredis#connect-to-redis
                        port: 6379,
                        host: "redis-server",
                        password: "123456",
                        db: 3
                    }
    
                    // Serializer
                    serializer: "JSON",
    
                    // Full heartbeat checks. It generates more network traffic
                    // 10 means every 10 cycle.
                    fullCheck: 10,
    
                    // Key scanning size
                    scanLength: 100,
    
                    // Monitoring Redis commands
                    monitor: true,
                    
                    // --- COMMON DISCOVERER OPTIONS ---
    
                    // Send heartbeat in every 10 seconds
                    heartbeatInterval: 10,
    
                    // Heartbeat timeout in seconds
                    heartbeatTimeout: 30,
    
                    // Disable heartbeat checking & sending, if true
                    disableHeartbeatChecks: false,
    
                    // Disable removing offline nodes from registry, if true
                    disableOfflineNodeRemoving: false,
    
                    // Remove offline nodes after 10 minutes
                    cleanOfflineNodesTimeout: 10 * 60
                }
            }
        }    
    }
    

    To be able to use this Discoverer, install the ioredis module with the npm install ioredis --save command.

    Tip: To further network traffic reduction, you can use MsgPack/Notepack serializers instead of JSON.

    Etcd3 Discoverer

    This is an experimental module. Do not use it in production yet!

    This Discoverer uses an etcd3 server to discover Moleculer nodes. The heartbeat & discovery packets are stored in the server. Thanks to etcd3 lease solution, if a node crashed or disconnected unexpectedly, the etcd3 will remove its heartbeat keys from the server and other nodes can detect it.

    Example to connect local etcd3 server

    // moleculer.config.js
    module.exports = {
        registry: {
            discoverer: "Etcd3"
        }    
    }
    

    Example to connect remote etcd3 server

    // moleculer.config.js
    module.exports = {
        registry: {
            discoverer: "etcd3://etcd-server:2379"
        }    
    }
    

    Example with options

    // moleculer.config.js
    module.exports = {
        registry: {
            discoverer: {
                type: "Etcd3",
                options: {
                    etcd: {
                        // etcd3 connection options.
                        // More info: https://mixer.github.io/etcd3/interfaces/options_.ioptions.html
                        hosts: "etcd-server:2379",
                        auth: "12345678"
                    }
    
                    // Serializer
                    serializer: "JSON",
    
                    // Full heartbeat checks. It generates more network traffic
                    // 10 means every 10 cycle.
                    fullCheck: 10,
                    
                    // --- COMMON DISCOVERER OPTIONS ---
    
                    // Send heartbeat in every 10 seconds
                    heartbeatInterval: 10,
    
                    // Heartbeat timeout in seconds
                    heartbeatTimeout: 30,
    
                    // Disable heartbeat checking & sending, if true
                    disableHeartbeatChecks: false,
    
                    // Disable removing offline nodes from registry, if true
                    disableOfflineNodeRemoving: false,
    
                    // Remove offline nodes after 10 minutes
                    cleanOfflineNodesTimeout: 10 * 60
                }
            }
        }    
    }
    

    To be able to use this Discoverer, install the etcd3 module with the npm install etcd3--save command.

    Tip: To further network traffic reduction, you can use MsgPack/Notepack serializers instead of JSON.

    Custom Discoverer

    You can create your custom Discoverer. We recommend to copy the source of Redis Discoverer and implement the necessary methods.

    Other changes

    • fixed multiple heartbeat sending issue at transporter reconnecting.
    • the heartbeatInterval default value has been changed to 10 seconds.
    • the heartbeatTimeout default value has been changed to 30 seconds.
    • the heartbeat check logics use process uptime instead of timestamps in order to avoid issues with time synchronization or daylight saving.
    • Notepack serializer initialization issue fixed. It caused problem when Redis cacher uses Notepack serializer.
    • new removeFromArray function in Utils.
    • mcall method definition fixed in Typescript definition.
    • dependencies updated.
    Source code(tar.gz)
    Source code(zip)
  • v0.14.6(Apr 11, 2020)

    New NewRelic zipkin tracing exporter

    Thanks for @jalerg, there is a NewRelic tracing exporter. PR #713

    // moleculer.config.js
    {
        tracing: {
            enabled: true,
            events: true,
            exporter: [
                {
                    type: 'NewRelic',
                    options: {
                        // NewRelic Insert Key
                        insertKey: process.env.NEW_RELIC_INSERT_KEY,
                        // Sending time interval in seconds.
                        interval: 5,
                        // Additional payload options.
                        payloadOptions: {
                            // Set `debug` property in payload.
                            debug: false,
                            // Set `shared` property in payload.
                            shared: false,
                        },
                        // Default tags. They will be added into all span tags.
                        defaultTags: null,
                    },
                },
            ],
        },    
    }
    

    Other changes

    • fix stream chunking issue. PR #712
    • fix INFO packet sending issue after reconnecting
    • safely handling disconnected state for transporters (heartbeat queuing issue). PR #715
    • fix orphan response issue in case of streaming with disabled balancer. #709
    • update dependencies, audit fix
    Source code(tar.gz)
    Source code(zip)
  • v0.14.5(Mar 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
    Source code(tar.gz)
    Source code(zip)
  • v0.14.4(Mar 8, 2020)

  • v0.14.3(Feb 24, 2020)

  • v0.14.2(Feb 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()
    };
    
    Source code(tar.gz)
    Source code(zip)
  • v0.14.1(Feb 12, 2020)

  • v0.14.0(Feb 12, 2020)

    :tada: 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.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 }
                    ]
                }
            }
        }
    };
    
    Source code(tar.gz)
    Source code(zip)
  • v0.13.13(Feb 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 }
                    ]
                }
            }
        }
    };
    
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0-rc2(Jan 29, 2020)

Owner
MoleculerJS
Microservices framework
MoleculerJS
🔬 Writing reliable & fault-tolerant microservices in Node.js

A Node.js microservices toolkit for the NATS messaging system Run on repl.it Node: v6+ Documentation: https://hemerajs.github.io/hemera/ Lead Maintain

HemeraJs 800 Dec 14, 2022
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications on top of TypeScript & JavaScript (ES6, ES7, ES8) 🚀

A progressive Node.js framework for building efficient and scalable server-side applications. Description Nest is a framework for building efficient,

nestjs 53.2k Dec 31, 2022
Asynchronous HTTP microservices

Disclaimer: Micro was created for use within containers and is not intended for use in serverless environments. For those using Vercel, this means tha

Vercel 10.3k Jan 4, 2023
Zeronode - minimal building block for NodeJS microservices

Zeronode - minimal building block for NodeJS microservices Why Zeronode? Installation Basics Benchmark API Examples Basic Examples Basic Examples [Adv

Steadfast 120 Oct 21, 2022
Catberry is an isomorphic framework for building universal front-end apps using components, Flux architecture and progressive rendering.

Catberry What the cat is that? Catberry was developed to help create "isomorphic/Universal" Web applications. Long story short, isomorphic/universal a

Catberry.js 801 Dec 20, 2022
Fast, unopinionated, minimalist web framework for node.

Fast, unopinionated, minimalist web framework for node. const express = require('express') const app = express() app.get('/', function (req, res) {

null 59.5k Jan 5, 2023
Realtime MVC Framework for Node.js

Website Get Started Docs News Submit Issue Sails.js is a web framework that makes it easy to build custom, enterprise-grade Node.js apps. It is design

Balderdash 22.4k Dec 31, 2022
Fast and low overhead web framework, for Node.js

An efficient server implies a lower cost of the infrastructure, a better responsiveness under load and happy users. How can you efficiently handle the

Fastify 26k Jan 2, 2023
🚀 The Node.js Framework highly focused on developer ergonomics, stability and confidence

Sponsored by FOSS United is a non-profit foundation that aims at promoting and strengthening the Free and Open Source Software (FOSS) ecosystem in Ind

AdonisJS Framework 13.4k Dec 31, 2022
MVC framework making it easy to write realtime, collaborative applications that run in both Node.js and browsers

Derby The Derby MVC framework makes it easy to write realtime, collaborative applications that run in both Node.js and browsers. Derby includes a powe

DerbyJS 4.7k Dec 23, 2022
Node.js framework

Node.js framework Total.js framework is a framework for Node.js platfrom written in pure JavaScript similar to PHP's Laravel or Python's Django or ASP

Total.js 4.2k Jan 2, 2023
🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈

Midway - 一个面向未来的云端一体 Node.js 框架 English | 简体中文 ?? 欢迎观看 Midway Serverless 2.0 发布会回放: https://www.bilibili.com/video/BV17A411T7Md 《Midway Serverless 发布

Midway.js 6.3k Jan 8, 2023
:evergreen_tree: Modern Web Application Framework for Node.js.

Trails is a modern, community-driven web application framework for Node.js. It builds on the pedigree of Rails and Grails to accelerate development by

Trails 1.7k Dec 19, 2022
Marble.js - functional reactive Node.js framework for building server-side applications, based on TypeScript and RxJS.

Functional reactive Node.js framework for building server-side applications, based on TypeScript and RxJS. Ecosystem Name Description @marblejs/core F

Marble.js 2.1k Dec 16, 2022
A serverless web framework for Node.js on AWS (CloudFormation, CloudFront, API Gateway, Lambda)

---- Sorry, this project is not maintained anymore. ---- dawson is a serverless web framework for Node.js on AWS (CloudFormation, CloudFront, API Gate

dawson 717 Dec 30, 2022
The React Framework

Next.js Getting Started Visit https://nextjs.org/learn to get started with Next.js. Documentation Visit https://nextjs.org/docs to view the full docum

Vercel 98.6k Jan 5, 2023
The Intuitive Vue Framework

Build your next Vue.js application with confidence using Nuxt: a framework making web development simple and powerful. Links ?? Documentation: https:/

Nuxt 41.8k Jan 9, 2023
The Simple, Secure Framework Developers Trust

@hapi/hapi The Simple, Secure Framework Developers Trust Build powerful, scalable applications, with minimal overhead and full out-of-the-box function

hapi.js 14.1k Dec 31, 2022
A framework for real-time applications and REST APIs with JavaScript and TypeScript

A framework for real-time applications and REST APIs with JavaScript and TypeScript Feathers is a lightweight web-framework for creating real-time app

Feathers 14.3k Jan 1, 2023