# @applicaster/zapp-pipes-dev-kit

> Development Kit for applicaster Zapp-Pipes datasource plugins

Latest version **1.4.7** (published 2024-05-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install @applicaster/zapp-pipes-dev-kit
pnpm add @applicaster/zapp-pipes-dev-kit
yarn add @applicaster/zapp-pipes-dev-kit
bun add @applicaster/zapp-pipes-dev-kit
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.7 |
| Published | 2024-05-15 |
| First published | 2017-04-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 6 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Applicaster |
| Maintainers | zapp-ci, meirmanr, applicaster-devs, applicaster-external-devs |
| Keywords | applicaster, plugin, datasource, zapp, zapp-pipes |

## Links

- npm: https://www.npmjs.com/package/@applicaster/zapp-pipes-dev-kit
- npm.io page: https://npm.io/package/@applicaster/zapp-pipes-dev-kit

## Dependencies (6)

- [url](https://npm.io/package/url.md) 0.11.0
- [hapi](https://npm.io/package/hapi.md) 17.5.4
- [chalk](https://npm.io/package/chalk.md) 1.1.3
- [ramda](https://npm.io/package/ramda.md) 0.26.1
- [raven-js](https://npm.io/package/raven-js.md) 3.14.1
- [query-string](https://npm.io/package/query-string.md) 4.3.2

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.4.7 (latest) — 2024-05-15
- 1.4.0-rc.2 (next) — 2019-10-24
- 1.4.6 — 2024-05-15
- 1.4.5 — 2023-09-28
- 1.4.4 — 2023-09-28
- 1.4.3 — 2023-09-28
- 1.4.2 — 2021-09-25
- 1.4.1 — 2019-10-25
- 1.4.0 — 2019-10-24
- 1.4.0-rc.1 — 2019-10-24
- 1.4.0-rc.0 — 2019-10-24
- 1.3.0 — 2019-05-30
- 1.2.8 — 2019-02-26
- 1.2.7 — 2018-09-21
- 1.2.6 — 2018-08-17
- … 24 more at https://npm.io/package/@applicaster/zapp-pipes-dev-kit/versions

## README

# zapp-pipes-dev-kit

This project contains the Zapp-pipes development kit to develop, test, and deploy zapp-pipes bundles.

## How to use

The dev kit enables to different modes for running a zapp-pipes bundle :

* server mode : creates a node.js server which can be used for testing requests.
* library mode : creates a bundle which can be used directly inside an app

**the Dev Kit is not intended to build production bundles - but only as a way to develop and test new providers.**

### Installation

* with npm : run `yarn add @applicaster/zapp-pipes-dev-kit`
  or
* clone this repo locally, install dependencies, and require it by its path

### API :

#### server mode

* Import the `createZappPipesServer` function from the dev kit. This function takes an configuration object as parameter, and returns the full hapi server object, plus a function to start the server

```javascript
// signature
const config = {
  options: { port: 8080, host: "localhost" }, // optionnal. these are the default values
  providers: [providers] // array of providers to load
};

// returns

server = {
  ...hapiServerObject, // hapi server
  startServer // function to start the server
};
```

* Import your provider(s) from other packages or local code, then invoke the method.

```javascript
import { createZappPipesServer } from "zapp-pipes-dev-kit";
import provider from "your-provider-packeage";

const zappPipesServer = createZappPipesServer({ providers: [provider] });
// zappPipesServer contains the full Hapi properties so you can add routes, invoke the start function directly, etc...

// or simply start the server with its basic configuration
zappPipesServer.startServer();
```

you can then visit `http://{host}:{port}` to test the requests

#### Library mode

The library mode is used to package the provider(s) as they would when they are built for the app
follow these steps :

* Import the `createZappPipesLibrary` function. This functions take an array of providers and the release name (used to identify the library in Sentry) as parameters, and returns a `ZappPipesGetter` class which is the entry point of the zapp-pipes js bundle

```javascript
import { createZappPipesLibrary } form 'zapp-pipes-dev-kit';
import provider form 'path-to-your-provider';

class ZappPipesGetter = {
  constructor() {
    this.get = createZappPipesLibrary({ providers: [provider], release: 'release-name' });
  }
}

export { ZappPipesGetter };

// you can now use this class to perform request like the app would.

const zappPipes = new ZappPipesGetter();
zappPipes.get('provider-name://fetchData?type=XXX&url=YYY', console.log);
```

### native bridge injection

In each mode, server or library, you can inject a custom native bridge to allow providers to interact with the environment.
the native bridge is a module which is injected in the provider's handler function, and provides several features.

In Zapp-iOS and Zapp-Android, there is no need to define a custom native bridge. But if you're using this package locally, on the server, or on any other environment, you have the ability to do so. Here's what a custom native bridge module looks like, and how to inject it :

```javascript
// All methods are optional since the custom nativeBridge is merged with the
// default one. Customizing the appData() function will do in most cases

const nativeBridge = {
  sendResponse(response, code) {}, // hook invoked when the provider returns its data
  log(...messages) {}, // log function which can be used in providers and customised dependending on the environment
  throwError(reason) {}, // hook invoked when the providers returns an error
  appData() {} // function which gives the provider some data regarding the native environment (platform, bundle identifier, account Id, broadcaster Id, uuid...);
};

// library mode
const zappPipesGetter = createZappPipesLibrary({
  providers,
  release,
  nativeBridge
});

// server mode
const zappPipesServer = createZappPipesServer({
  providers,
  release,
  nativeBridge
});
```

## For development

* Clone this repo
* Install dependencies with `yarn` or `npm install`

---
_Source: https://npm.io/package/@applicaster/zapp-pipes-dev-kit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
