New release is coming soon! If you want to try out the latest features, simply run npm i -s moleculer@next. The docs for the latest version are available here.

Examples

Project examples

Realworld backend server

This is a RealWorld.io example backend server with Moleculer microservices framework.

Key features

  • 7 microservices
  • NeDB or MongoDB database without Mongoose
  • User login & signup
  • User authentication with JWT
  • Memory caching
  • Docker files

Repo: https://github.com/moleculerjs/moleculer-examples/tree/master/conduit#readme

Blog

This is a simple blog example.

Key features

Repo: https://github.com/moleculerjs/moleculer-examples/blob/master/blog#readme

Short examples

The main Moleculer repository contains some examples.

To try them, at first, you should clone the Moleculer repo with the following command:

git clone https://github.com/moleculerjs/moleculer.git

Simple

This is a simple demo with a Math service which can add, sub, mult and divide two numbers.

$ npm run demo simple

Source code is available on Github

Server & client nodes

In this example, you can start any servers & clients. The servers serve the math.add action and clients call it in a loop. You can start multiple instances from both.
They use TCP transporter, but you can change it with TRANSPORTER env variable.

Start a server

$ node examples/client-server/server

Start a client

$ node examples/client-server/client

Source code is available on Github

Middlewares

This example demonstrates how the middleware system works.

$ npm run demo middlewares

Source code is available on Github

Runner

This example shows how you can start a broker and load services with Moleculer Runner

$ node ./bin/moleculer-runner.js -c examples/runner/moleculer.config.js -r examples/user.service.js

It starts a broker with options from moleculer.config.js, loads the user service from user.service.js file and switch to REPL mode.

Source code is available on Github

Load tester

With this example, you can start a load test. The server & client prints how many requests executed in a second.

Start server

$ node examples/loadtest/server

Start & fork clients (number of CPU cores)

$ node examples/loadtest/clients

Source code is available on Github