How to test your provider locally

Zapp-pipes provides a development kit package which allows easy local testing of a provider. Using this development kit requires an NPM token as it is a private npm package. In order to be able to use the development kit, follow the following steps :

  1. ask your applicaster representative for an npm token, define it as an environment variable on your system, and set up your .npmrc file to use this token

  2. install the development kit by running npm install @applicaster/zapp-pipes-dev-kit --save

  3. install nodemon as a dev dependency by running npm install --save-dev nodemon. This will enable automatic reloading of the server when you edit the code.

  4. Create a file at the root of your project folder called server.js with the following content :

const {createZappPipesServer} = require('@applicaster/zapp-pipes-dev-kit');
const provider = require('./src');

const zappPipesServer = createZappPipesServer({ providers: [provider] });
  1. in your package.json file, add a start script with the following command node_modules/.bin/nodemon server.js --exec node_modules/.bin/babel-node. This command assumes your provider is using babel as a transpiler, and you will need the babel-cli package in your project

  2. Execute the start script by running npm start.

From this point, you should have a local node.js server which enables you to test your provider by entering the feed url in a web browser. the local node.js server should be accessible at http://localhost:8080. However, since you are now running on a web server, the request needs to go through local node.js server's url. To test a feed url in the browser, you will need to construct the datasource url manually to achieve something like this : http://localhost:8080/{provider-name}/fetchData?type=${FEED_TYPE}&url=${ENCODED_FEED_URL}

Encoding the feed url is required so that there is no parsing error between the datasource url and the feed url. To manually encode a URL, open the chrome console and type encodeURIComponent(btoa(", then enter. This will give you the ${ ENCODED_FEED_URL } you need to test your feed

For instance, if you have a feed of type 'collection', and the url is '', the test request in the browser will become http://localhost:8080/my-provider/fetchData?type=collection&url=aHR0cDovL215ZmVlZHVybC5jb20vZmVlZC54bWw%3D

NB : When running the provider as a server for testing, you don't have access to all the app bridge data. if you need specific data, you can add those parameters to the data source url : http://localhost:8080/my-provider/fetchData?type=collection&url=aHR0cDovL215ZmVlZHVybC5jb20vZmVlZC54bWw%3D&uuid=12345678

results matching ""

    No results matching ""