Example Task: Linktree
This Koii task is the second task in our series of explaining Koii tasks. The Google Doodle task takes you through the process of turning a simple JavaScript program into a Koii task using the K2 Task Template. This tutorial will build on that and teach you how to use databases across many Koii nodes.
A LinkTree is a customized profile page that contains all your important links.
The images below show a few examples of the Koii linktree:
You can explore the deployed application here and the source code.
Once you have cloned the project, navigate to the task-template-linktree folder
cd task-template-linktree
Navigate to the test folder
cd test
You will find some pre-written tests here. You can go through the tests for all the files explained in this tutorial. Once you have a better understanding of the files discussed in this tutorial, feel free to edit these tests to familiarize yourself better with their implementation. You will need a strong understanding of these concepts for writing your Koii tasks.
The goal of this tutorial is to familiarize you with more advanced topics that will help you write your own Koii tasks.
What Will You Learn in This Tutorial?β
This tutorial's goal is to familiarize you with more advanced concepts that are applied in the linktree task, such as database management and API endpoints. Writing your own Koii tasks will be made easier for you if you have a good understanding of these features.
However, when it comes to more complex projects involving database management and the creation of API endpoints for user requests, several questions arise. let's talk about three crucial pieces of logic needed for this project to function properly:
File | Description |
---|---|
db_model.js | A local database is required to store and manage data such as Linktree information, proofs, and the authentication list on a node operator's local device. This is important because it reduces the need for frequent API calls to a remote database. |
routes.js | API endpoints will be required for the project to handle incoming requests, process data, and return appropriate responses to the client. |
db_sharing.js | Since each Koii node has its local database, when one nodeβs data is updated, it must also be updated on other nodes to ensure consistency. The db_sharing.js will contain a single function called share() that works to keep the network synchronized. |
If you encounter any difficulties, feel free to contact us at Koii support or chat with us at Discord.