Closed futpib closed 6 years ago
Good idea. I tried and you can use it with +1 extra line:
const { ServiceBroker } = require("moleculer");
const broker = new ServiceBroker({ logger: true });
broker.createService({
name: "greeter",
actions: {
hello(ctx) {
return "Hello!";
},
}
});
broker.start().then(() => require("repl").start("mol $ ").context.broker = broker);
Output:
mol $ broker.call("greeter.hello").then(console.log)
mol $ Hello!
I often find myself running both moleculer REPL and a node one on two separate terminals, this makes for a really productive development environment in my opinion. But this leaves no (easy) way to transfer data back and forth.
What if instead moleculer REPL was built on node.js repl module with an extra exported global (or multiple globals)? Let's assume one global variable
M
for example.Now
Call an action
Work with action result
Not available.
JS alternative
This will get better when node repl gets
await
support.Call an action
Work with action result