# @tshio/command-bus

> Command Bus

Latest version **1.0.4** (published 2022-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tshio/command-bus
pnpm add @tshio/command-bus
yarn add @tshio/command-bus
bun add @tshio/command-bus
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2022-03-04 |
| First published | 2020-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | tsh.io |
| Maintainers | vviktor, theunderscorer, aherok, sethii, barograf, mkopa |

## Links

- npm: https://www.npmjs.com/package/@tshio/command-bus
- Repository: https://github.com/TheSoftwareHouse/node-common
- Homepage: https://github.com/TheSoftwareHouse/node-common#readme
- Issues: https://github.com/TheSoftwareHouse/node-common/issues
- npm.io page: https://npm.io/package/@tshio/command-bus

## Recent versions

- 1.0.4 (latest) — 2022-03-04
- 1.0.3 — 2021-02-24
- 1.0.2 — 2020-12-18
- 1.0.1 — 2020-12-14
- 0.0.1 — 2020-12-10

## README

# Command Bus

[![npm version](https://badge.fury.io/js/%40tshio%2Fcommand-bus.svg)](https://badge.fury.io/js/%40tshio%2Fcommand-bus)


**Non-blocking Command Bus library for Node.js.**

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

## Installing

```bash
$ npm install @tshio/command-bus
```
or
```bash
yarn add @tshio/command-bus
```

## Usage

```ts
// CommonJS
const { Command, CommandBus, CommandHandler } = require('@tshio/command-bus');

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


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](https://img.shields.io/badge/license-MIT-4dc71f.svg)](https://raw.githubusercontent.com/TheSoftwareHouse/node-common/master/LICENSE)

This project is licensed under the terms of the [MIT license](/LICENSE).

## About us:

<a href="https://tsh.io"><b>The Software House</b></a>

<img src="https://raw.githubusercontent.com/TheSoftwareHouse/node-common/master/assets/tsh.png" alt="tsh.png" width="150"  />

---
_Source: https://npm.io/package/@tshio/command-bus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
