The IOTA Data Marketplace: a technical introduction

The full article was originally published by Alexey Sobolev on Medium. Read the full article here.

Part 5: Checkout and Deploy your application

https://data.iota.org

In the previous article in this series, we talked about cloud backend configuration. Today we will learn how to checkout, build and deploy your version of the Data Marketplace application.

1. Install Node.js and NPM package manager

Please check this page to see how to install Node.js

2. Install Firebase tools

You need to install Firebase CLI in order to deploy your application to Firebase.

The Firebase CLI (GitHub) provides a variety of tools for managing, viewing, and deploying to Firebase projects.

Once you’ve installed Node.js, you can install the Firebase CLI using npm (the Node Package Manager) by running the following command:

npm install -g firebase-tools

You should now have a globally available firebase command available from any terminal window on your machine.

3. Firebase Login

Once you’ve installed the Firebase CLI, sign in using your Google account:

firebase login

This command connects your local machine to your Firebase account and grants access to your projects.

To test that authentication worked, you can run firebase list to see a list of all of your Firebase projects.

4. Checkout project

Checkout the latest version of the Data Marketplace into a folder on your machine.

If you are familiar with Git, you can clone the repository by running the following command inside a folder, where you want this project to reside.

git clone git@github.com:iotaledger/data-marketplace.git

Alternatively you can go to the open sourced project page and download the latest release as shown on the screenshot below:

5. Install packages

After you cloned or downloaded and unzipped the project, you need to install required packages. Please open a Terminal/Console application, navigate to the folder with the project source code and run the following command:

npm run install-all

This operation can take several minutes, please do not interrupt it.

6. Get Firebase project configuration

Proceed to the https://console.firebase.google.com and select your project.

Click on the gear wheel icon and select “Project settings”.

Scroll down on the page to the “Your apps” section. Click on the right circle “Add Firebase to your web app” (marked with red border on the screenshot below) to display project configuration.

Please consider the 4 lines of the project configuration as shown on the screenshot below. You’ll need it to connect your app with the backend.

7. Update config.json

Open the project folder, find a file named “config.json.example” in the “src” folder and rename it to “config.json”.

Open the “config.json” and replace values for apiKey, authDomain, databaseURL, and projectId with values that you retrieved from Firebase.

For the last parameter, domain, please replace only the placeholder XXXXXXXXXXXXXXXXX with the value of projectId. So your final config file should look as the one shown below (with your valid api key and unique project ID)

8. Deploy project

To deploy the application to firebase, you will need to have your project ID one more time.

Run the following command:

npm run deploy YOUR_PROJECT_ID

Please replace YOUR_PROJECT_ID with the real ID of your project.

In my example the command will look like npm run deploy data-marketplace-demo.

This operation can take several minutes, please do not interrupt it.

Once it is ready, you can start using your application.

Proceed to the https://YOUR_PROJECT_ID.firebaseapp.com to see it in action.

Please replace YOUR_PROJECT_ID with the real ID of your project.

In my example the URL will look like https://data-marketplace-demo.firebaseapp.com

9. Adjust function max allowed runtimes to prevent timeouts.

Some functions of the application can run longer that the default allowed runtime of 60 sec. If the function is interrupted, the operation can not be successfully completed and might result in data inconsistency. Therefore I suggest to adjust function runtimes to prevent this from happening. This can be done in a few steps:

1. Open https://console.cloud.google.com/functions/list, from the dropdown menu on the very top of the page select your project.

1. Open https://console.cloud.google.com/functions/list, from the dropdown menu on the very top of the page select your project.

2. You will be presented with a list of functions. Please follow steps 3–7 for every of these functions: newDevice, wallet, stream, purchaseStream.

2. You will be presented with a list of functions. Please follow steps 3–7 for every of these functions: newDevice, wallet, stream, purchaseStream

3. Click on the function name, you will be redirected to a function details page. Click on the Edit button

3. Click on the function name, you will be redirected to a function details page. Click on the Edit button

4. On the Edit screen scroll to the very bottom of the page, then click More

4. On the Edit screen scroll to the very bottom of the page, then click More

5. In the Advanced options adjust the Timeout value. I recommend to set a value between 360 and 540 seconds. Press Save button on the very bottom.

5. In the Advanced options adjust the Timeout value. I recommend to set a value between 360 and 540 seconds. Press Save button on the very bottom.

6. Wait until the function is updated. A blue spinner will indicate the progress.

6. Wait until the function is updated. A blue spinner will indicate the progress.

7. Once the function is updated, return to the functions list by pressing the Cloud Functions button, and proceed with the next function.

7. Once the function is updated, return to the functions list by pressing the Cloud Functions button, and proceed with the next function.

Part 1: IOTA Data Marketplace — Update

Part 2: Sensor Onboarding

Part 3: Publishing Sensor Data

Part 4: Cloud Backend Configuration

Part 5: Checkout and Deploy

The full article was originally published by Alexey Sobolev on Medium, where people are continuing the conversation by highlighting and responding to this story. Read the full article here.

You might also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More