The Connector Class

Reshuffle have a wide rage of connectors that exposes events and action on 3rd party services.

Registering event handlers

A common use case of integrations and workflows is to register code that will be called when an event happens on a 3rd party system. Example can be an handler that is called when an email comes through a POP3 server, or a new customer is added to Salesforce.

Using the appropriate service connector, you can register a handler using the on(options, handler, eventId?)method.

The on(options, handler, eventId?) method

  • options: parameters used to define the event for example, in the CronService {interval:5000} will tell the connector to emit an event every 5 sec.
  • handler: this is the code of the event handler, when this event is emitted, the handler is called.
  • eventId: an optional identifier that will be the key the Reshuffle app uses to map the event to the handler, automatically generated if not supplied.

The on method is use to register event handlers, here is an example:

const s3Connector = new AWSS3Connector(app, {
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  bucket: process.env.AWS_BUCKET,

s3Connector.on({ type: 'ObjectAdded' }, async (event, app) => {

When a connector emits more than one event type, you must use the {type:eventType} to specify which type of event you are subscribing to.

Expose service actions

Each service may expose different actions you can preform on the remote service. Here is an example of exposing an endpoint that lists S3 object keys:

httpConnector.on({ method: 'GET', path: '/list' }, async (event, app) => {
  const keys = await s3Connector.listObjectKeys()

Starting and stopping a connector.

Each connector supports starting and stopping a connection to a service. In most use cases you do not need to call start or stop - the Reshuffle class automatically calls it when you call it's start() method, and all connectors stop when the app execution end.