# @superbalist/js-pubsub-rest-proxy

> An HTTP server which acts as a gateway for publishing messages via a js-pubsub adapter

Latest version **1.2.2** (published 2019-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @superbalist/js-pubsub-rest-proxy
pnpm add @superbalist/js-pubsub-rest-proxy
yarn add @superbalist/js-pubsub-rest-proxy
bun add @superbalist/js-pubsub-rest-proxy
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2019-05-20 |
| First published | 2019-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 20.6 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Superbalist.com a division of Takealot Online |
| Maintainers | bradwhittington, mike-faut, zoidbergwill |
| Keywords | pubsub, rest |

## Links

- npm: https://www.npmjs.com/package/@superbalist/js-pubsub-rest-proxy
- Repository: https://github.com/Superbalist/js-pubsub-rest-proxy
- Homepage: https://github.com/Superbalist/js-pubsub-rest-proxy#readme
- Issues: https://github.com/Superbalist/js-pubsub-rest-proxy/issues
- npm.io page: https://npm.io/package/@superbalist/js-pubsub-rest-proxy

## Dependencies (12)

- [ajv](https://npm.io/package/ajv.md) ^5.0.1
- [debug](https://npm.io/package/debug.md) ~2.6.3
- [queue](https://npm.io/package/queue.md) ^4.2.1
- [raven](https://npm.io/package/raven.md) ^2.0.1
- [morgan](https://npm.io/package/morgan.md) ^1.8.1
- [amqplib](https://npm.io/package/amqplib.md) ^0.5.3
- [express](https://npm.io/package/express.md) ^4.15.3
- [winston](https://npm.io/package/winston.md) ^2.3.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.17.2
- [prom-client](https://npm.io/package/prom-client.md) ^10.2.2
- [@superbalist/js-event-pubsub](https://npm.io/package/@superbalist/js-event-pubsub.md) ^3.0.2
- [@superbalist/js-pubsub-manager](https://npm.io/package/@superbalist/js-pubsub-manager.md) ^3.0.1

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.2.2 (latest) — 2019-05-20
- 1.2.1 — 2019-05-20
- 1.2.0 — 2019-05-20

## README

# js-pubsub-rest-proxy

An HTTP server which acts as a gateway for publishing messages via a [js-pubsub](https://github.com/Superbalist/js-pubsub) adapter.

[![Author](http://img.shields.io/badge/author-@superbalist-blue.svg?style=flat-square)](https://twitter.com/superbalist)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![NPM Version](https://img.shields.io/npm/v/@superbalist/js-pubsub-rest-proxy.svg)](https://www.npmjs.com/package/@superbalist/js-pubsub-rest-proxy)
[![NPM Downloads](https://img.shields.io/npm/dt/@superbalist/js-pubsub-rest-proxy.svg)](https://www.npmjs.com/package/@superbalist/js-pubsub-rest-proxy)

This service wraps the [js-pubsub-manager](https://github.com/Superbalist/js-pubsub-manager) library which bundles support
for the following adapters:
* Local
* /dev/null
* Redis
* Google Cloud

It exposes a `/messages/(channel)` end-point where messages can be POSTed to.

eg:
```
POST /messages/test HTTP/1.1
Content-Type: application/json

{
	"messages": [
		"Hello World",
		{
			"another": "message"
		}
	]
}
```

This is an async end-point which queues messages for background publishing.

The [js-pubsub-http](https://github.com/Superbalist/js-pubsub-http) adapter is a client-side implementation for publishing
messages via this service.

## Installation

The service is available as a docker image OR an npm package.

```bash
npm install @superbalist/js-pubsub-rest-proxy
```

## Environment Variables

When you start the `js-pubsub-rest-proxy` image, you can adjust the configuration of the instance by passing one or more environment variables on the docker run command line.

| Env Var                        | Default   | Description                                                        |
|--------------------------------|-----------|--------------------------------------------------------------------|
| PORT                           | 3000      | The port the web server will listen on                             |
| LOG_LEVEL                      | info      | The log level (silly, debug, verbose, info, warn, error)           |
| SENTRY_DSN                     | null      |                                                                    |
| MAX_POST_SIZE                  | 10mb      | The max post size for request payloads                             |
| PUBSUB_CONNECTION              | redis     | The pub/sub connection to use (/dev/null, local, redis, gcloud)    |
| REDIS_HOST                     | localhost |                                                                    |
| REDIS_PORT                     | 6379      |                                                                    |
| GOOGLE_CLOUD_PROJECT_ID        | null      |                                                                    |
| GOOGLE_APPLICATION_CREDENTIALS | null      | The full path to the file containing the Google Cloud credentials  |
| GOOGLE_CLOUD_CLIENT_IDENTIFIER | null      | The client identifier used when talking to Google Cloud            |
| VALIDATION_ERROR_SCHEMA_URL    | false     | The url for invalid event schema below. Enables validation         |
| VALIDATION_ERROR_CHANNEL       | validation_error | The channel to publish validation errors to                 |
| PUBLISH_INVALID                | true      | Publish invalid events (true, false)                               |
| RABBITMQ_FALLBACK              | false     | Whether the fallback should be used or now (true, false)           |
| RABBITMQ_URL                   | pubsub-rest-proxy-rabbitmq| Url with rabbitmq fallback                         |
| RABBITMQ_USER                  | guest     | Rabbitmq user                                                      |
| RABBITMQ_PASSWORD              | guest     | Should be a base64 encoded string (guest == Z3Vlc3Q=)              |

## Running

1. Start a container using the Redis Pub/Sub adapter
```bash
$ docker run \
  -d \
  --rm \
  --name js-pubsub-rest-proxy \
  -e PUBSUB_CONNECTION='redis' \
  -e REDIS_HOST='127.0.0.1' \
  -e REDIS_PORT='6379' \
  superbalist/js-pubsub-rest-proxy
```

2. Start a container using the Google Cloud Pub/Sub adapter
```bash
$ docker run \
  -d \
  --rm \
  --name js-pubsub-rest-proxy \
  -e PUBSUB_CONNECTION='gcloud' \
  -e GOOGLE_CLOUD_PROJECT_ID='your-project-id-here' \
  -e GOOGLE_APPLICATION_CREDENTIALS='/etc/gcloud_credentials.json' \
  superbalist/js-pubsub-rest-proxy
```

## Validation Error Schema
```
"properties": {
  "schema": {
      "type": "string",
      "format": "uri"
  },
  "meta": {
      "type": "object"
  },
  "event": {
      "type": "object"
  },
  "errors": {
      "type": "array"
  }
}
```

---
_Source: https://npm.io/package/@superbalist/js-pubsub-rest-proxy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
