REPL console

moleculer repl npm

The moleculer-repl is an interactive developer console for Moleculer.

Install

npm install moleculer-repl --save

Usage

Switch broker to REPL mode

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

REPL Commands

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

List nodes

mol $ nodes

Options

-d, --details Detailed list
-a, --all List all (offline) nodes

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 actions
-i, --skipinternal Skip internal actions
-d, --details Print endpoints

Output
image

List events

mol $ events

Options

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

Output
!TODO!

Show common informations

mol $ info

Output
image

Call an action

mol $ call "test.hello"

Call an action with parameters

mol $ call "math.add" --a 5 --b Bob --c --no-d --e.f "hello"

Params will be { a: 5, b: 'Bob', c: true, d: false, e: { f: 'hello' } }

Direct call

Get health info of node-12 node

mol $ dcall "node-12" "$node.health"

Emit an event

mol $ emit "user.created"

Emit an event with parameters

mol $ emit "user.created" --a 5 --b Bob --c --no-d --e.f "hello"

Params will be { a: 5, b: 'Bob', c: true, d: false, e: { f: 'hello' } }

Load a service from file

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

Load all services from a folder

mol $ load "./services"