![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
moleculer
Advanced tools
Moleculer is a progressive microservices framework for Node.js.
Website: https://moleculer.services
Documentation: https://moleculer.services/docs
$ npm install moleculer --save
or
$ yarn add moleculer
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
let broker = new ServiceBroker({ logger: console });
// 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}`));
Use the Moleculer CLI tool to create a new Moleculer based microservices project.
Install moleculer-cli globally
$ npm install moleculer-cli -g
Create a new project (named first-demo
)
$ moleculer init project first-demo
Press Y on API Gateway &
npm install
Open project folder
$ cd first-demo
Start project
$ npm run dev
Open the http://localhost:3000/ link in your browser. It shows a start page which contains two links to call the greeter
service via API gateway.
:tada:Congratulations! Your first Moleculer based microservices project is created. Read our documentation to learn more about Moleculer.
We have many official modules for Moleculer. Check our list!
Moleculer is an open source project. It is free to use for your personal or commercial projects. However, developing it takes up all my free time to make it better and better on a daily basis. If you like Moleculer framework, please support it.
Thank you very much!
You can find here the documentation.
See CHANGELOG.md.
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
We welcome you to join to the development of Moleculer. Please read our contribution guide.
Moleculer is available under the MIT license.
Copyright (c) 2016-2018 MoleculerJS
0.13.13 (2020-02-11)
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 withnpm install rhea-promise --save
command.
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
}
};
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 }
]
}
}
}
};
<a name="0.13.12"></a>
FAQs
Fast & powerful microservices framework for Node.JS
The npm package moleculer receives a total of 28,431 weekly downloads. As such, moleculer popularity was classified as popular.
We found that moleculer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.