Remove all HKD/satshkd support, keep only EUR version

- Removed all HKD routes (/en, /zh-cn, /zh-hk) from index.js
- Removed HKD locale files (en.json, zh-cn.json, zh-hk.json)
- Removed HKD calculation files (calculate.js, btcpoll.js, updaterate.js from old version)
- Removed HKD historical data files (hkd_historical, hkd_historical_dedup)
- Renamed EUR-specific files to standard names:
  - calculate-eur.js -> calculate.js
  - btcpoll-eur.js -> btcpoll.js
  - updaterate-eur.js -> updaterate.js
  - eur_historical -> historical
- Updated all locale files to reference 'historical' instead of 'eur_historical'
- Updated default route to redirect to /en-eur instead of /en
- Updated GitHub Actions workflow to only run EUR data updates
- Updated all references in code to use renamed files

This creates a clean EUR-only implementation ready for deployment at eursat.eu
This commit is contained in:
Claude
2025-11-09 09:36:33 +00:00
parent 292eebd9b3
commit 447f740f59
22 changed files with 40 additions and 278 deletions

View File

@@ -1,14 +1,14 @@
# This is a basic workflow to help you get started with Actions
# Daily job at 04:05 GMT
name: Simple update btc rates
name: Update EUR BTC rates
on:
schedule:
- cron: '5 4 * * *'
jobs:
run:
name: update hkdhistorical
name: update eurhistorical
runs-on: ubuntu-latest
steps:
- name: setup actions
@@ -24,7 +24,6 @@ jobs:
npm install
npm install axios@0.26.1 --save
node updaterate.js
node updaterate-eur.js
date > generated.txt
git config user.name github-actions
git config user.email github-actions@github.com

View File

@@ -1,80 +0,0 @@
const fs = require('fs')
const axios = require('axios');
const moment = require('moment');
const path = require('path');
const dirPath = path.join(__dirname, ".");
const fileToWrite = dirPath + "/public/eur_historical"
const fileToRead = dirPath + "/public/eur_historical"
// get btc/usd and btc/eur daily rate
async function BTCDaily() {
let url = "https://api.coingecko.com/api/v3/coins/bitcoin/history?localization=false&date="
const yesterday = moment().subtract(1, 'days') // YYYY-MM-DD
const reverse = yesterday.format('DD-MM-YYYY')
// format is YYYY-MM-DD
const dbdate = yesterday.format('YYYY-MM-DD')
let full_url = url + reverse
let row = {}
//console.log("db date: ", dbdate)
//console.log("new date format: ", reverse, "\n")
await axios.get(full_url).then(
async function(response) {
// console.log("full url: ", full_url)
const data = await response.data;
const btcusd = data['market_data']['current_price']['usd']
const btceur = data['market_data']['current_price']['eur']
const satsrate = 100000000
const sateur = parseInt(satsrate / btceur)
const usdsat = parseInt(satsrate / btcusd)
row = {
btcusd_rate: parseInt(btcusd),
date: dbdate,
usdsat_rate: usdsat,
sateur_rate: sateur,
btceur_rate: parseFloat(btceur).toFixed(2),
}
console.log("row data: ", row)
})
return row
}
// update file in the target github repo
async function updateFile() {
const row = await BTCDaily()
//const row = []
if (Object.keys(row).length > 0) {
//console.log("dirpath", dirPath)
//console.log("dirname", __dirname)
const original = await fs.readFileSync(fileToRead)
let orig = JSON.parse(original)
//console.log(orig[0])
orig.push(row)
//console.log(orig[orig.length - 1])
const new_content = JSON.stringify(orig)
await fs.writeFileSync(fileToWrite, new_content);
}
}
module.exports = {
// start here
main: async function () {
console.log("starting btcpoll script for sateur....")
let result = updateFile();
console.log(result)
return true
}
}
//const res = main()
//console.log('Result from main() : ', res)

View File

@@ -4,11 +4,11 @@ const moment = require('moment');
const path = require('path');
const dirPath = path.join(__dirname, ".");
const fileToWrite = dirPath + "/public/hkd_historical"
const fileToRead = dirPath + "/public/hkd_historical"
const fileToWrite = dirPath + "/public/historical"
const fileToRead = dirPath + "/public/historical"
// get btc/usd and btc/hkd daily rate
// get btc/usd and btc/eur daily rate
async function BTCDaily() {
let url = "https://api.coingecko.com/api/v3/coins/bitcoin/history?localization=false&date="
@@ -27,17 +27,17 @@ async function BTCDaily() {
// console.log("full url: ", full_url)
const data = await response.data;
const btcusd = data['market_data']['current_price']['usd']
const btchkd = data['market_data']['current_price']['hkd']
const btceur = data['market_data']['current_price']['eur']
const satsrate = 100000000
const sathkd = parseInt(satsrate / btchkd)
const sateur = parseInt(satsrate / btceur)
const usdsat = parseInt(satsrate / btcusd)
row = {
btcusd_rate: parseInt(btcusd),
date: dbdate,
usdsat_rate: usdsat,
sathkd_rate: sathkd,
btchkd_rate: parseFloat(btchkd).toFixed(2),
sateur_rate: sateur,
btceur_rate: parseFloat(btceur).toFixed(2),
}
console.log("row data: ", row)
})
@@ -63,10 +63,10 @@ async function updateFile() {
}
module.exports = {
// start here
main: async function () {
console.log("starting btcpoll script for satshkd....")
console.log("starting btcpoll script for sateur....")
let result = updateFile();
console.log(result)
return true

View File

@@ -1,58 +0,0 @@
const axios = require('axios')
const fs = require('fs');
module.exports = {
bfx: async function() {
const eurrate = 0.92 // approximate EUR/USD rate
const btcDataURL = "https://api-pub.bitfinex.com/v2/ticker/tBTCUSD"
const response = await axios.get(btcDataURL)
const data = response.data
//console.log(data[6])
const satDenominator = 100000000
// see docs : https://docs.bitfinex.com/reference#rest-public-ticker
btcLastPrice = data[6]
const sateur = Math.round((1 / btcLastPrice) * satDenominator * eurrate)
//console.log("bitfinex last price: ", btcLastPrice, "current satEUR: ", sateur)
return sateur
},
get10yr: async function() {
// console.log("get10yr")
try {
// const content = await fs.readFile('./public/eur_historical')
const content = fs.readFileSync('./public/eur_historical', { encoding: 'utf8' })
const historical = JSON.parse(content)
hist_entries = []
let datelist = []
// get all the years you need from 1 - 10
for (let i = 1; i < 11; i++) {
const y = new Date(new Date().setFullYear(new Date().getFullYear() - i)).toISOString().slice(0, 10)
datelist.push(y)
}
for (let j = 0; j < historical.length; j++) {
const hdate = historical[j]['date']
if (datelist.includes(hdate)) {
hist_entries.push(historical[j])
}
}
// console.log(hist_entries)
let final_list = []
let today_sats = await this.bfx()
for (var v = 0; v < hist_entries.length; v++) {
const date = new Date(hist_entries[v]['date'])
year = date.getFullYear();
rawsat = hist_entries[v]['sateur_rate']
percentage = (-100 * ((rawsat - today_sats) / rawsat)).toFixed(3)
final_list.push({ "year": date.toLocaleDateString(), "sats": rawsat.toLocaleString("en-US"), "percent": percentage });
}
return final_list.reverse()
} catch (error) {
console.error("Error trying to read file ", error)
}
}
}

View File

@@ -3,7 +3,7 @@ const fs = require('fs');
module.exports = {
bfx: async function() {
const hkdrate = 0.1287 // approximate rate
const eurrate = 0.92 // approximate EUR/USD rate
const btcDataURL = "https://api-pub.bitfinex.com/v2/ticker/tBTCUSD"
const response = await axios.get(btcDataURL)
const data = response.data
@@ -13,16 +13,16 @@ module.exports = {
// see docs : https://docs.bitfinex.com/reference#rest-public-ticker
btcLastPrice = data[6]
const sathkd = Math.round((1 / btcLastPrice) * satDenominator * hkdrate)
//console.log("bitfinex last price: ", btcLastPrice, "current satHKD: ", sathkd)
return sathkd
const sateur = Math.round((1 / btcLastPrice) * satDenominator * eurrate)
//console.log("bitfinex last price: ", btcLastPrice, "current satEUR: ", sateur)
return sateur
},
get10yr: async function() {
// console.log("get10yr")
try {
// const content = await fs.readFile('./public/hkd_historical')
const content = fs.readFileSync('./public/hkd_historical', { encoding: 'utf8' })
// const content = await fs.readFile('./public/historical')
const content = fs.readFileSync('./public/historical', { encoding: 'utf8' })
const historical = JSON.parse(content)
hist_entries = []
@@ -45,7 +45,7 @@ module.exports = {
for (var v = 0; v < hist_entries.length; v++) {
const date = new Date(hist_entries[v]['date'])
year = date.getFullYear();
rawsat = hist_entries[v]['sathkd_rate']
rawsat = hist_entries[v]['sateur_rate']
percentage = (-100 * ((rawsat - today_sats) / rawsat)).toFixed(3)
final_list.push({ "year": date.toLocaleDateString(), "sats": rawsat.toLocaleString("en-US"), "percent": percentage });
}
@@ -55,4 +55,4 @@ module.exports = {
}
}
}
}

View File

@@ -11,11 +11,7 @@ const handlebars = require('express-handlebars');
const port = 3000;
const calculate = require('./calculate')
const calculateEur = require('./calculate-eur')
const zhcnjson = require('./locales/zh-cn.json');
const zhhkjson = require('./locales/zh-hk.json');
const enjson = require('./locales/en.json');
const eneurjson = require('./locales/en-eur.json');
const enjson = require('./locales/en-eur.json');
const dejson = require('./locales/de.json');
const frjson = require('./locales/fr.json');
const esjson = require('./locales/es.json');
@@ -43,45 +39,20 @@ app.use(express.static(path.join(__dirname, 'public', 'css')));
app.get('/', function(req, res) {
res.redirect('/en');
res.redirect('/en-eur');
});
app.get('/en', function(req, res) {
// EUR routes
app.get('/en-eur', function(req, res) {
calculate.get10yr().then(pydata => {
// console.log("get10yr: ", pydata)
const yeardata = { 'yeardata': pydata }
let endata = Object.assign(enjson, yeardata)
res.render('sats', endata)
})
});
app.get('/zh-cn', function(req, res) {
calculate.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let zhcndata = Object.assign(zhcnjson, yeardata)
res.render('sats', zhcndata)
})
});
app.get('/zh-hk', function(req, res) {
calculate.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let zhhkdata = Object.assign(zhhkjson, yeardata)
res.render('sats', zhhkdata)
})
});
// EUR routes
app.get('/en-eur', function(req, res) {
calculateEur.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let eneurdata = Object.assign(eneurjson, yeardata)
res.render('sats', eneurdata)
})
});
app.get('/de', function(req, res) {
calculateEur.get10yr().then(pydata => {
calculate.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let dedata = Object.assign(dejson, yeardata)
res.render('sats', dedata)
@@ -89,7 +60,7 @@ app.get('/de', function(req, res) {
});
app.get('/fr', function(req, res) {
calculateEur.get10yr().then(pydata => {
calculate.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let frdata = Object.assign(frjson, yeardata)
res.render('sats', frdata)
@@ -97,7 +68,7 @@ app.get('/fr', function(req, res) {
});
app.get('/es', function(req, res) {
calculateEur.get10yr().then(pydata => {
calculate.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let esdata = Object.assign(esjson, yeardata)
res.render('sats', esdata)
@@ -105,7 +76,7 @@ app.get('/es', function(req, res) {
});
app.get('/it', function(req, res) {
calculateEur.get10yr().then(pydata => {
calculate.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let itdata = Object.assign(itjson, yeardata)
res.render('sats', itdata)
@@ -113,7 +84,7 @@ app.get('/it', function(req, res) {
});
app.get('/nl', function(req, res) {
calculateEur.get10yr().then(pydata => {
calculate.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let nldata = Object.assign(nljson, yeardata)
res.render('sats', nldata)
@@ -121,7 +92,7 @@ app.get('/nl', function(req, res) {
});
app.get('/pt', function(req, res) {
calculateEur.get10yr().then(pydata => {
calculate.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let ptdata = Object.assign(ptjson, yeardata)
res.render('sats', ptdata)
@@ -129,7 +100,7 @@ app.get('/pt', function(req, res) {
});
app.get('/pl', function(req, res) {
calculateEur.get10yr().then(pydata => {
calculate.get10yr().then(pydata => {
const yeardata = { 'yeardata': pydata }
let pldata = Object.assign(pljson, yeardata)
res.render('sats', pldata)

View File

@@ -15,7 +15,7 @@
"price": "Preis",
"percentchange": "Prozentuale Änderung",
"footnote": "Datenquelle von usdsat.com, angepasst für EUR",
"data_file": "eur_historical",
"data_file": "historical",
"rate_field": "sateur_rate",
"exchange_rate": "0.92",
"lang1_link": "/en-eur/",

View File

@@ -15,7 +15,7 @@
"price": "Price",
"percentchange": "Percent Change",
"footnote": "data source from usdsat.com, adapted for EUR",
"data_file": "eur_historical",
"data_file": "historical",
"rate_field": "sateur_rate",
"exchange_rate": "0.92",
"lang1_link": "/de/",

View File

@@ -1,25 +0,0 @@
{
"post": {
"author": "Janith Kasun",
"image": "https://picsum.photos/500/500",
"comments": [
"This is the first comment",
"This is the second comment",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nec fermentum ligula. Sed vitae erat lectus."
]
},
"layout": "main",
"Title": "1 HK dollar is currently worth ",
"subtitle": "HKDSAT Historical Performance",
"date": "Date",
"price": "Price",
"percentchange": "Percent Change",
"footnote": "data source from usdsat.com, adapted for HKD",
"data_file": "hkd_historical",
"rate_field": "sathkd_rate",
"exchange_rate": "7.75",
"lang1_link": "/zh-cn/",
"lang1": "中文(中国)",
"lang2_link": "/zh-hk/",
"lang2": "中文(香港)"
}

View File

@@ -15,7 +15,7 @@
"price": "Precio",
"percentchange": "Cambio Porcentual",
"footnote": "fuente de datos de usdsat.com, adaptado para EUR",
"data_file": "eur_historical",
"data_file": "historical",
"rate_field": "sateur_rate",
"exchange_rate": "0.92",
"lang1_link": "/en-eur/",

View File

@@ -15,7 +15,7 @@
"price": "Prix",
"percentchange": "Variation en Pourcentage",
"footnote": "source de données de usdsat.com, adaptée pour EUR",
"data_file": "eur_historical",
"data_file": "historical",
"rate_field": "sateur_rate",
"exchange_rate": "0.92",
"lang1_link": "/en-eur/",

View File

@@ -15,7 +15,7 @@
"price": "Prezzo",
"percentchange": "Variazione Percentuale",
"footnote": "fonte dati da usdsat.com, adattato per EUR",
"data_file": "eur_historical",
"data_file": "historical",
"rate_field": "sateur_rate",
"exchange_rate": "0.92",
"lang1_link": "/en-eur/",

View File

@@ -15,7 +15,7 @@
"price": "Prijs",
"percentchange": "Procentuele Verandering",
"footnote": "gegevensbron van usdsat.com, aangepast voor EUR",
"data_file": "eur_historical",
"data_file": "historical",
"rate_field": "sateur_rate",
"exchange_rate": "0.92",
"lang1_link": "/en-eur/",

View File

@@ -15,7 +15,7 @@
"price": "Cena",
"percentchange": "Zmiana Procentowa",
"footnote": "źródło danych z usdsat.com, dostosowane dla EUR",
"data_file": "eur_historical",
"data_file": "historical",
"rate_field": "sateur_rate",
"exchange_rate": "0.92",
"lang1_link": "/en-eur/",

View File

@@ -15,7 +15,7 @@
"price": "Preço",
"percentchange": "Variação Percentual",
"footnote": "fonte de dados de usdsat.com, adaptado para EUR",
"data_file": "eur_historical",
"data_file": "historical",
"rate_field": "sateur_rate",
"exchange_rate": "0.92",
"lang1_link": "/en-eur/",

View File

@@ -1,15 +0,0 @@
{
"Title": "1 港币现值 ",
"subtitle": "HKDSAT 过往表现",
"date": "日期",
"price": "价格",
"percentchange": "百分比变化",
"footnote": "来自usdsat.com的数据源",
"data_file": "hkd_historical",
"rate_field": "sathkd_rate",
"exchange_rate": "7.75",
"lang1_link": "/",
"lang1": "EN",
"lang2_link": "/zh-hk/",
"lang2": "中文(香港)"
}

View File

@@ -1,15 +0,0 @@
{
"Title": "1 港幣現值 ",
"subtitle" : "HKDSAT 過往表現",
"date" : "日期",
"price" : "價格",
"percentchange" : "百分比變化",
"footnote" : "來自usdsat.com的數據源",
"data_file": "hkd_historical",
"rate_field": "sathkd_rate",
"exchange_rate": "7.75",
"lang1_link": "/zh-cn/",
"lang1": "中文(中国)",
"lang2_link": "/",
"lang2": "EN"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,13 +0,0 @@
const core = require('@actions/core');
const poll = require('./btcpoll-eur');
// modify this to ping url, get data and update, commit and push file to github repo
try {
const res = poll.main()
console.log("main response: ", res)
core.setOutput('✅ Success');
} catch (error) {
core.setFailed(`🛑 ${error.message}`);
}

View File

@@ -8,6 +8,6 @@ try {
core.setOutput('✅ Success');
} catch (error) {
core.setFailed(`🛑 ${error.message}`);
core.setFailed(`🛑 ${error.message}`);
}