# chainsaws

> Provides abstraction layer to really tighten up use of Asynchronous Messaging style architecture with AWS services

Latest version **0.0.4** (published 2015-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install chainsaws
pnpm add chainsaws
yarn add chainsaws
bun add chainsaws
```

## 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.0.4 |
| Published | 2015-12-30 |
| First published | 2015-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Obie Fernandez |
| Maintainers | obie |
| Keywords | aws |

## Links

- npm: https://www.npmjs.com/package/chainsaws
- Repository: https://github.com/obie/chainsaws
- Homepage: https://github.com/obie/chainsaws#readme
- Issues: https://github.com/obie/chainsaws/issues
- npm.io page: https://npm.io/package/chainsaws

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2015-12-30
- 0.0.3 — 2015-12-30
- 0.0.2 — 2015-12-30
- 0.0.1 — 2015-12-30

## README

![Chainsaws](https://dl.dropboxusercontent.com/u/1770482/Chainsaws.png)

## Purpose

Provides abstraction layer for core AWS application services such as SNS and SQS so that your microservices don't end up tightly coupled to the platform. Helps immensely with testability and other concerns related to maintaining a so-called hexagonal architecture. <http://alistair.cockburn.us/Hexagonal+architecture>

Perfect for Serverless architecture style. Learn more at <http://leanpub.com/serverless>

## Installing

```sh
npm install chainsaws
```

## Usage

Initialize with the `AWS` sdk instance.

```javascript
var AWS = require('aws-sdk');
var Chainsaws = new require('chainsaws')(AWS);
```

### Stage Variable

Set a value for the stage variable to indicate which environment you're running in. This is useful in conjunction with frameworks such as <http://serverless.com>

```javascript
// defaults to 'development'
Chainsaws.stage = process.env.SERVERLESS_STAGE;
```

Instantiate chainsaws for topics and queues as needed.

### SNS (Simple Notification Service)

Start by instantiating a topic object.

```javascript
var topic = new Chainsaws.Topic("NewOrders");
```

#### Automatic Topic Creation

Creating a `Topic` will automatically create an SNS Topic on AWS if it does not already exist. The value of `Chainsaw.stage` is appended to the topic name.

#### Sending messages

Send a message using `publish`. First argument is the payload, second is a callback to be invoked when publishing is done.

```javascript
topic.publish("a new order has arrived", function(err, data) { ... });
```

The callback is invoked when a response from the service is returned.  The context of the callback (`this`) is set to the response object containing error, data properties, and the original request object.

**`data`** is an object with the de-serialized data returned from the request with a ` MessageId` property corresponding to the unique identifier string identifier assigned by SNS to the published message.

#### Expects to be using JSON as payload format

Payload is automatically run through `JSON.stringify()`.

```javascript
var topic = new Chainsaws.Topic(topicArn);
topic.publish({foo: "bar"}, done);
```

### SQS (Simple Queue Service)

```javascript
var queue = new Chainsaws.Queue(url);
queue.publish({foo: "bar"}, done);
```

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