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
- Docker files
- ExpressJS www server with Pug
- MongoDB database with moleculer-db and moleculer-db-adapter-mongoose modules
- NATS transporter
- Redis cacher
- Traefik reverse proxy (in micro arch)
- static frontend
Repo: https://github.com/moleculerjs/moleculer-examples/blob/master/blog#readme
Short examples
The main Moleculer repository contains some examples.
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 |