Skip to content

Commit

Permalink
Merge pull request #2 from Sotatek-QuangDo/feat/call-api-webflow-part…
Browse files Browse the repository at this point in the history
…ners

feat(form project submission): call api get list, insert, update item collection partners
  • Loading branch information
praveen-kaia authored Sep 30, 2024
2 parents 4bef4ee + 54715ea commit c426725
Show file tree
Hide file tree
Showing 7 changed files with 758 additions and 2 deletions.
14 changes: 13 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,17 @@ COINGECKO_API_KEY=
COIN_GECKO_BASE_URL="https://api.coingecko.com/api/v3/coins/markets?x_cg_demo_api_key="
COIN_GECKO_POSTFIX="&vs_currency=usd&ids=klay-token"

# info form submission projects and partner
TOKEN_AUTH_WEBSTIE=a33077fa53b1abb014ccd189ae77f7744080865286ae6fd3f88d92eee25dad53
COLLECTION_PARTNER_ID=66a8ba5239a3fbe8e678dae4
FORM_ID_SUBMISSION_PROJECTS=66b0c1cb15d49137ecd3e59c
FORM_ID_SUBMISSION_IOK=66c9a377866d1ce393c8b686
COLLECTION_CATEGORIES_PARTNERS_ID=66a8ba5239a3fbe8e678db00

# In milliseconds ex: 24*60*60*1000 => every 24 hours
JOB_INTERVAL=86400000
JOB_INTERVAL=86400000
CALL_INTERVAL_API=10*60*1000

# Kaia Releases
KAIACHAIN_GITHUB_API="https://api.github.com/repos/kaiachain/kaia/releases?per_page=100"
KAIACHAIN_GITHUB_API_KEY=
16 changes: 15 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ var StatsData = {};
const { Flipside } = require("@flipsidecrypto/sdk");
require("dotenv").config();

require("./services/partner.js");
const kaiachainService = require("./services/kaiachainService.js");

const flipside = new Flipside(
process.env.FLIPSIDE_API_KEY,
process.env.FLIPSIDE_API_URL
Expand All @@ -27,8 +30,19 @@ app.get("/health", async function (req, res) {
return res.status(200).json({ success: true });
});

app.get('/node/releases', async (req, res) => {
try {
let start = parseInt(req.query.start || "0");
let results = await kaiachainService.getKaiaNodeReleasesCache(start);
return res.status(200).json({success: true, data: results});
} catch(err) {
console.log(err.message);
return res.status(404).json({success: false, message: err.message})
}
});

app.get("/*", async function (req, res) {
return res.status(200).json({ success: true, message: 'Kaia Websites API' });
return res.status(200).json({ success: true, message: 'Kaia Websites API' });
});

const TRANSACTION_COUNT_SQL = `select count(distinct tx_hash) as total_transactions
Expand Down
37 changes: 37 additions & 0 deletions services/kaiachainService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
let machineTypes = require("./machineTypes.js");
let klaytnReleases = require("./klaytnReleases.js");
let config = require("./releaseConfig.js");
global.releases = [];
let service = {};

service.getKaiaNodeReleases = async () => {
let releases = await fetch(
process.env.KAIACHAIN_GITHUB_API,
{
method: "GET",
headers: {
Accept: "application/vnd.github+json",
Authorization: "Bearer "+process.env.KAIACHAIN_GITHUB_API_KEY,
"X-GitHub-Api-Version": "2022-11-28",
},
}
).then((response) => response.json());
releases = releases.map((_release) => ({
tag_name: _release.tag_name,
type: "kaia",
created_at: _release.created_at,
}));

global.releases = [...releases, ...klaytnReleases];
console.log("Updated Node Releases");
};

service.getKaiaNodeReleasesCache = async (start = 0, size = 10) => {
return {
releases: global.releases.slice(start, start + size),
machineTypes,
config,
};
};

module.exports = service;
189 changes: 189 additions & 0 deletions services/klaytnReleases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
const klaytnReleases = [
{
"tag_name": "v1.12.1",
"type": "klaytn",
"created_at": "2024-02-01T01:31:55Z"
},
{
"tag_name": "v1.12.0",
"type": "klaytn",
"created_at": "2023-12-11T01:32:06Z"
},
{
"tag_name": "v1.11.1",
"type": "klaytn",
"created_at": "2023-09-12T13:12:24Z"
},
{
"tag_name": "v1.11.0",
"type": "klaytn",
"created_at": "2023-08-14T05:28:12Z"
},
{
"tag_name": "v1.10.2",
"type": "klaytn",
"created_at": "2023-03-17T10:18:22Z"
},
{
"tag_name": "v1.10.1",
"type": "klaytn",
"created_at": "2023-01-06T06:57:45Z"
},
{
"tag_name": "v1.10.0",
"type": "klaytn",
"created_at": "2022-12-27T07:30:35Z"
},
{
"tag_name": "v1.9.1",
"type": "klaytn",
"created_at": "2022-08-19T07:08:25Z"
},
{
"tag_name": "v1.9.0",
"type": "klaytn",
"created_at": "2022-07-28T09:41:28Z"
},
{
"tag_name": "v1.8.4",
"type": "klaytn",
"created_at": "2022-05-20T04:10:16Z"
},
{
"tag_name": "v1.8.3",
"type": "klaytn",
"created_at": "2022-04-27T02:07:32Z"
},
{
"tag_name": "v1.8.2",
"type": "klaytn",
"created_at": "2022-03-23T09:22:52Z"
},
{
"tag_name": "v1.8.1",
"type": "klaytn",
"created_at": "2022-03-18T05:23:02Z"
},
{
"tag_name": "v1.8.0",
"type": "klaytn",
"created_at": "2022-03-16T09:18:05Z"
},
{
"tag_name": "v1.7.3",
"type": "klaytn",
"created_at": "2021-12-27T07:59:11Z"
},
{
"tag_name": "v1.7.2",
"type": "klaytn",
"created_at": "2021-12-07T05:37:12Z"
},
{
"tag_name": "v1.7.1",
"type": "klaytn",
"created_at": "2021-11-16T02:17:41Z"
},
{
"tag_name": "v1.7.0",
"type": "klaytn",
"created_at": "2021-10-19T02:19:30Z"
},
{
"tag_name": "v1.6.4",
"type": "klaytn",
"created_at": "2021-10-01T05:04:27Z"
},
{
"tag_name": "v1.6.3",
"type": "klaytn",
"created_at": "2021-07-01T11:35:21Z"
},
{
"tag_name": "v1.6.2",
"type": "klaytn",
"created_at": "2021-05-18T05:09:00Z"
},
{
"tag_name": "v1.6.1",
"type": "klaytn",
"created_at": "2021-04-26T07:31:11Z"
},
{
"tag_name": "v1.6.0",
"type": "klaytn",
"created_at": "2021-02-18T13:28:42Z"
},
{
"tag_name": "v1.5.3",
"type": "klaytn",
"created_at": "2020-10-28T10:00:11Z"
},
{
"tag_name": "v1.5.2",
"type": "klaytn",
"created_at": "2020-09-22T08:42:18Z"
},
{
"tag_name": "v1.5.2-rc.2",
"type": "klaytn",
"created_at": "2020-09-02T00:08:57Z"
},
{
"tag_name": "v1.5.2-rc.1",
"type": "klaytn",
"created_at": "2020-08-19T02:17:37Z"
},
{
"tag_name": "v1.5.1",
"type": "klaytn",
"created_at": "2020-08-11T02:00:44Z"
},
{
"tag_name": "v1.5.0",
"type": "klaytn",
"created_at": "2020-07-08T02:17:47Z"
},
{
"tag_name": "v1.4.2",
"type": "klaytn",
"created_at": "2020-04-08T05:43:44Z"
},
{
"tag_name": "v1.4.1",
"type": "klaytn",
"created_at": "2020-04-01T06:44:52Z"
},
{
"tag_name": "v1.4.0",
"type": "klaytn",
"created_at": "2020-03-26T08:30:45Z"
},
{
"tag_name": "v1.3.0",
"type": "klaytn",
"created_at": "2019-12-16T09:00:09Z"
},
{
"tag_name": "v1.2.0",
"type": "klaytn",
"created_at": "2019-10-21T05:27:11Z"
},
{
"tag_name": "v1.2.0-rc.1",
"type": "klaytn",
"created_at": "2019-09-17T10:23:15Z"
},
{
"tag_name": "v1.1.1",
"type": "klaytn",
"created_at": "2019-08-21T09:09:51Z"
},
{
"tag_name": "v1.1.0",
"type": "klaytn",
"created_at": "2019-08-14T11:50:09Z"
}
];

module.exports = klaytnReleases;
Loading

0 comments on commit c426725

Please sign in to comment.