Command Bus
npm install @tshio/command-bus
Non-blocking Command Bus library for Node.js.
This is a 100% JavaScript library, with TypeScript definition, with the Promise API.
``bash`
$ npm install @tshio/command-bus`
orbash`
yarn add @tshio/command-bus
`ts
// CommonJS
const { Command, CommandBus, CommandHandler } = require('@tshio/command-bus');
// ES Module
import { Command, CommandBus, CommandHandler } from '@tshio/command-bus';
class TestHandler implements CommandHandler
public commandType: string = "test-type";
async execute(command: Command
return handler-message ${command.payload};
}
}
const bus = new CommandBus([new TestHandler()]);
const testCommand: Command
payload: "payload-data",
type: "test-type",
};
const result = await bus.execute(testCommand);
console.log(result);
// => "handler-message payload-data"
``

This project is licensed under the terms of the MIT license.