@lifechurch/subserver
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@lifechurch/subserver

Subserver is a background server process for processing messages from Google Pub/Sub.

Usage

Install

yarn add @lifechurch/subserver @google-cloud/pubsub

Start

import Subserver from '@lifechurch/subserver';
import { handlers } from './handlers';

const handler = message => {
  // perform some action
  message.ack();
};

const config = {
  subscribers: [
    {
      name: 'subscription',
      queue: 'default',
      handler: handler,
    }
  ],
  queue: 'default', // optional
  keepAliveInterval: 1000 * 60 * 60 //optional
};

Subserver.start(config);

Configuration

Property Type Description
subscribers Array name: Name of the Subscription
queue: Queue to process the Subscription on
handler: Listener function to execute when a message is received
queue String Name of the queue to process the subscription on
livenessPort Number The port in which to run the liveness server (Default: 4000)

Local Development

Below is a list of commands you will probably find useful.

yarn build

Bundles the package to the dist folder. The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).

yarn test

Runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.

Readme

Keywords

none

Package Sidebar

Install

npm i @lifechurch/subserver

Weekly Downloads

8

Version

2.0.0

License

MIT

Unpacked Size

19.6 kB

Total Files

13

Last publish

Collaborators

  • ajesseperez
  • michael.haglund