Examples

The main repo of Moleculer contains some examples.

Simple

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

$ npm run demo simple

Source code is available on Github

Caching

This example demonstrates how the cacher module works.

$ npm run demo caching

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

Transporters

This example starts two brokers and communicates together via NATS server.

$ npm run demo transporters

Source code is available on Github

Multiple servers & clients

In this example you can start any servers & clients. The servers serve the math.add action and clients call it in a loop.

Start a server

$ node examples/multi-server/server

Start a client

$ node examples/multi-server/client

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 (count of CPU cores)

$ node examples/loadtest/clients

Source code is available on Github