Socket
Book a DemoInstallSign in
Socket

@tshio/command-bus

Package Overview
Dependencies
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tshio/command-bus

Command Bus

Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
157
26.61%
Maintainers
5
Weekly downloads
 
Created
Source

Command Bus

npm version

Non-blocking Command Bus library for Node.js.

This is a 100% JavaScript library, with TypeScript definition, with the Promise API.

Installing

$ npm install @tshio/command-bus

or

yarn add @tshio/command-bus

Usage

// CommonJS
const { Command, CommandBus, CommandHandler } = require('@tshio/node-common');

// ES Module
import { Command, CommandBus, CommandHandler } from '@tshio/node-common';


default class TestHandler implements CommandHandler<Command<string>> {
  public commandType: string = "test-type";

  async execute(command: Command<string>) {
    return `handler-message ${command.payload}`;
  }
}


const bus = new CommandBus([new TestHandler()]);

const testCommand: Command<string> = {
  payload: "payload-data",
  type: "test-type",
};

const result = await bus.execute(testCommand);

console.log(result);

// => "handler-message payload-data"

License

license

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

About us:

The Software House

tsh.png

FAQs

Package last updated on 10 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts