11.9.1 • Published 2 years ago

@clinq/bridge v11.9.1

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
2 years ago

CLINQ Bridge Framework

This is the CLINQ Bridge framework for developing integration services. It provides a unified way to connect the CLINQ web application to any contact provider.

Bootstrapping a new bridge

If you want to bootstrap a new CLINQ Bridge you can use this repository: clinq-bridge-boilerplate

Installation

npm install --save @clinq/bridge
# or
yarn add @clinq/bridge

Quick Start

CLINQ accepts contacts in this format:

{
  id: "abc123",
  // Provide either the full name or first and last name, not both
  name: null, // or null
  firstName: "Walter", // or null
  lastName: "Geoffrey", // or null
  organization: "Rocket Science Inc.", // or null
  contactUrl: "http://myapp.com/contacts/abc123", // or null
  avatarUrl: "http://myapp.com/avatar/abc123.png", // or null
  email: "walter@example.com", // or null
  phoneNumbers: [
    {
      label: "MOBILE", // or "WORK" or "HOME"
      phoneNumber: "+4915799912345"
    }
  ]
}

The minimum adapter implements the getContacts method:

const bridge = require("@clinq/bridge");
const fetch = require("node-fetch");

const { ServerError } = bridge;

const adapter = {
  getContacts: async ({ apiKey, apiUrl }) => {
    // Fetch contacts using apiKey and apiUrl or throw on error
    const response = await fetch(`${apiUrl}/api/contacts`, {
      headers: { Authorization: `Bearer ${apiKey}` },
    });

    if (response.status === 401) {
      throw new ServerError(401, "Unauthorized");
    }

    if (response.ok) {
      const contacts = await response.json();
      // TODO: Convert contact to the structure above
      return contacts;
    } else {
      throw new ServerError(500, "Could not fetch contacts");
    }
  },
};

bridge.start(adapter);

Configuration

The CLINQ Bridge support configuration through the following environment variables

  • REDIS_URL: URL of a Redis instance to cache responses, otherwise memory cache will be used
  • CACHE_DISABLED: Disable caching
  • CACHE_REFRESH_INTERVAL: Time a contact in cache is not refreshed (in seconds), only used if redis or memory cache is active
11.8.11

2 years ago

11.8.12

2 years ago

11.8.10

2 years ago

11.9.1

2 years ago

11.9.0

2 years ago

11.8.6

2 years ago

11.8.9

2 years ago

11.8.4

2 years ago

11.8.5

2 years ago

11.8.3

2 years ago

11.8.2

2 years ago

11.8.1

2 years ago

11.8.0

3 years ago

11.6.12

3 years ago

11.6.11

3 years ago

11.7.0

3 years ago

11.6.8

3 years ago

11.6.9

3 years ago

11.6.6

3 years ago

11.6.7

3 years ago

11.6.10

3 years ago

11.6.0

3 years ago

11.6.1

3 years ago

11.6.4

3 years ago

11.6.3

3 years ago

11.5.1

3 years ago

11.4.2

3 years ago

11.4.0

3 years ago

11.3.2

3 years ago

11.3.1

3 years ago

11.3.0

3 years ago

11.2.4

3 years ago

11.2.3

3 years ago

11.2.2

3 years ago

11.2.1

4 years ago

11.2.0

4 years ago

11.1.2

4 years ago

11.1.1

4 years ago

11.1.0

4 years ago

11.0.0

4 years ago

10.1.2

5 years ago

10.1.1

5 years ago

10.1.0

5 years ago

10.0.8

5 years ago

10.0.7

5 years ago

10.0.6

5 years ago

10.0.5

5 years ago

10.0.4

5 years ago

10.0.3

5 years ago

10.0.2

5 years ago

10.0.1

5 years ago

10.0.0

5 years ago

9.4.1

5 years ago

9.4.0

5 years ago

9.3.0

5 years ago

9.2.0

5 years ago

9.1.0

5 years ago

9.0.5

5 years ago

9.0.4

5 years ago

9.0.3

5 years ago

9.0.2

5 years ago

9.0.1

5 years ago

9.0.0

5 years ago

8.1.0

5 years ago

8.0.0

5 years ago

7.9.0

5 years ago

7.8.1

5 years ago

7.8.0

5 years ago

7.7.1

5 years ago

7.7.0

5 years ago

7.6.0

5 years ago

7.5.0

5 years ago

7.4.0

5 years ago

7.3.1

5 years ago

7.3.0

5 years ago

7.2.2

5 years ago

7.2.1

5 years ago

7.2.0

5 years ago

7.1.1

5 years ago

7.1.0

5 years ago

7.0.2

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago

6.0.0

5 years ago

5.1.2

5 years ago

5.1.1

5 years ago

5.1.0

5 years ago

5.0.0

6 years ago

4.0.0

6 years ago

3.2.0

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.0

6 years ago