REPL console

moleculer repl npm

The moleculer-repl is a REPL interactive console for Moleculer.

Install

npm install moleculer-repl --save

Usage

Start broker in REPL mode

let broker = new ServiceBroker({ logger: console });
// Start REPL
broker.repl();

REPL Commands

Commands:
help [command...] Provides help for a given command.
exit Exits application.
q Exit application
call <actionName> [params] Call an action
dcall <nodeID> <actionName> [params] Direct call an action
emit <eventName> [payload] Emit an event
load <servicePath> Load a service from file
loadFolder <serviceFolder> [fileMask] Load all service from folder
subscribe <eventName> Subscribe to an event
unsubscribe <eventName> Unsubscribe from an event
actions [options] List of actions
services [options] List of services
nodes [options] List of nodes
info Information from broker

List nodes

mol $ nodes

Options

-d, --details

Output
image

List services

mol $ services

Options

-l, --local Only local services
-i, --skipinternal Skip internal services

Output
image

List actions

mol $ actions

Options

-l, --local Only local services
-i, --skipinternal Skip internal services
-d, --details Print endpoints

Output
image

Show common informations

mol $ info

Output
image

Call an action

mol $ call "test.hello"

Call an action with params

mol $ call "math.add" '{"a": 5, "b": 4}'

Direct call

mol $ dcall server-2 "$node.health"

Emit an event

mol $ emit "user.created"

Subscribe to an event

mol $ subscribe "user.created"

Unsubscribe from an event

mol $ unsubscribe "user.created"

Load a service from file

mol $ load "./math.service.js"

Load all services from a folder

mol $ load "./services"