# simple-eventhubs-framework

> A simple framework for node services to use eventhubs

Latest version **0.1.6** (published 2022-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-eventhubs-framework
pnpm add simple-eventhubs-framework
yarn add simple-eventhubs-framework
bun add simple-eventhubs-framework
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2022-03-22 |
| First published | 2021-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 109.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Bren Norris |
| Maintainers | verikono |

## Links

- npm: https://www.npmjs.com/package/simple-eventhubs-framework
- Repository: https://github.com/verikono/simple-eventhubs-framework
- Homepage: https://github.com/verikono/simple-eventhubs-framework#readme
- Issues: https://github.com/verikono/simple-eventhubs-framework/issues
- npm.io page: https://npm.io/package/simple-eventhubs-framework

## Dependencies (5)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [@types/node](https://npm.io/package/@types/node.md) ^15.12.2
- [@azure/event-hubs](https://npm.io/package/@azure/event-hubs.md) ^5.5.2
- [simple-node-logger](https://npm.io/package/simple-node-logger.md) ^18.12.24

## Recent versions

- 0.1.6 (latest) — 2022-03-22
- 0.1.5 — 2022-03-19
- 0.1.4 — 2022-02-23
- 0.1.3 — 2022-02-23
- 0.1.2 — 2022-02-23
- 0.1.1 — 2022-02-22
- 0.1.0 — 2022-02-20
- 0.0.7 — 2021-06-11
- 0.0.6 — 2021-04-26
- 0.0.5 — 2021-03-03
- 0.0.4 — 2021-03-03
- 0.0.3 — 2021-02-19
- 0.0.2 — 2021-02-16

## README

Provided is an Event Beacon as 

```javascript
import { EventBeacon } from 'simple-eventhubs-framework';

const beacon = new EventBeacon();

const myListener = async event => {

    const {
        action,
        transaction_id,
        payload
    } = event;    
};
```

## EventBeacon.register
register callbacks

**props** the keyword argument object

**props.hub** string the eventhub to unregister the listener

**props.callback** Function the specific callback to unregister (optional), default: Any/All

**props.action** string the action to unregister callbacks for, default Any/All

**props.transaction_id** string the transactionId to unregister callbacks for, default Any/All.

**props.consumerGroup** string the consumergroup of the subscription, default "$Default"

**props.once** boolean when an acceptable event has been received, shut this down/unregister this listener.

**Returns** Promise resolved by boolean true on success

```javascript
const myCallbackFn = event => { ....custom event handler code..... }

await myBeaconInstance.register({
    hub: "myHub",
    action: "my-action",
    consumerGroup: "myConsumer",
    transaction_id: "some_specific_transaction_were_interested_in",
    once: true, // unregister once this event has been received and callback fired.
    callback: myCallbackFn
})

```


## EventBeacon.unregister
Unregister callbacks

**props** the keyword argument object

**props.hub** string the eventhub to unregister the listener

**props.callback** Function the specific callback to unregister (optional), default: Any/All

**props.action** string the action to unregister callbacks for, default Any/All

**props.transaction_id** string the transactionId to unregister callbacks for, default Any/All.

**props.consumerGroup** string the consumergroup of the subscription, default "$Default"

**Returns** Promise resolved by boolean true on success



```javascript

const myCallbackFn = event => { ....custom event handler code..... }

await myBeaconInstance.unregister({
    hub: "myhub",
    action: "my-action",
    transaction_id: "saf87-asdf897asf-asdf89asdf-sadf",
    consumerGroup: "$Default",
    callback: myCallbackFn
});

```
## EventBeacon.dispatch
Dispatch an event

**props** the keyword argument object

**props.hub** string the eventhub to unregister the listener

**props.action** string the action to unregister callbacks for, default Any/All

**props.transaction_id** string optional tracking id for this event

**props.payload**  object key/prop object for this event - must be JSON friendly (ie not cyclic, all key vals are primitives and not functions etc)

**Returns** Promise resolved by boolean true on success

```javascript

const result = await MyBeaconInstance.dispatch({
    hub: "myhub",
    action: "my-action"
    payload: {
        this: "that"
    }
})

```

---
_Source: https://npm.io/package/simple-eventhubs-framework · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
