This project aims to bridge the gap between the Koii Task Submissions and a standardized database.
- Reads submissions from a Koii Task.
- Extracts the referred data from IPFS using a submission list.
- Stores the data in a MongoDB database.
- Server API: Includes an Express.js server setup to manage keywords and receive task data updates.
It uses a queuing system to manage concurrency and ensure efficient processing.
- index.js: Main entry point that fetch task data every 15 minutes and save it to mongoDB.
- queue.js: Contains the logic for queuing the tasks, such as sending tweets and handling CID data and save data do mongoDB.
- server.js: Server setup to interact with the running Task.
- async-await-queue: For managing task concurrency.
- axios: For making HTTP requests.
- @_koii/web3.js: For interacting with the Koii blockchain.
- dotenv: For managing environment variables.
- node-cron: For scheduling the task data fetch.
- Install Dependencies Before running the project, make sure to install the required dependencies:
yarn
or
npm install
-
Configure .env file Ensure that the
TASK_ID
is properly configured in .env file. The mongoDB connection string is also required in .env file. -
Run the Project You can run the project by executing the following command:
yarn start
or
npm run start
This will start the process of fetching task data every 15 minutes and save it to mongoDB.
- main(): Keeps fetching task data every 15 minutes and save it to mongoDB.
-
queueCID(submissionList)
- Parameters:
- submissionList: An array of submission data including CIDs.
- Description: Extracts task data from IPFS using the provided CIDs.
- Parameters:
-
queuePost(tweetList, i)
- Parameters:
- tweetList: An array of tweet data.
- i: An index used for tracking the process.
- Description: Handles the queuing and sending of tweets to the server.
- Parameters:
- getTaskData(taskID, round): Gets the task Data and wait for new round to load
- dataFromCid(cid, filename): Gets the content from both IPFS Storage SDK and direct accessing (as backup)