Install Moleculer
You can install Moleculer with npm
$ npm install moleculer --save |
or with yarn
$ yarn add moleculer |
Create your first microservice
This example shows how you can create a small math
service to add two numbers.
const { ServiceBroker } = require("moleculer"); |
Try it in your browser!Open this example on Runkit!
Create a Moleculer project
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 moleculer-demo
Press Y to all questions
Open project folder
$ cd moleculer-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.
Congratulations!You have just created your first Moleculer-based microservices project! The next step is to check our examples or demo projects.