Closed mailaneel closed 6 years ago
Plus add created
& started
lifecycle handlers too.
The created
is called when the Runner created the ServiceBroker instance.
The started
is called after the broker.start()
.
Done. It will be released in v0.12
// moleculer.config.js
module.exports = {
logger: true,
// Add middlewares
middlewares: [myMiddleware()],
// Fired when the broker is created
created(broker) {
},
// Fired when the broker is started
started(broker) {
// You can return with Promise
return broker.Promise.resolve();
},
// Fired when the broker is stopped
stopped(broker) {
// You can return with Promise
return broker.Promise.resolve();
}
};
When using moleculer runner, there is no easy way to provide the middleware using suggested
moleculer.config.js
Without the above option, we still have to manually create broker and call
.use
for adding middleware.