Upgrade dependencies

This commit is contained in:
Dennis Reimann 2026-02-23 10:42:45 +01:00
parent 4447d290c2
commit 8f2ca99dbe
No known key found for this signature in database
GPG key ID: 5009E1797F03F8D0
5 changed files with 846 additions and 995 deletions

View file

@ -1,19 +0,0 @@
const btcFormat = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'BTC' })
module.exports = {
currency(code) {
switch (code) {
case 'USD':
return '$'
case 'EUR':
return '€'
default:
return code
}
},
sats2BTC(value) {
const btc = value/100000000
const formatted = btcFormat.format(btc)
return formatted.replace('BTC', '').replace(' ', '')
}
}

41
server/helpers.mjs Normal file
View file

@ -0,0 +1,41 @@
import { mkdirSync, writeFileSync } from 'fs'
import { dirname, join, resolve } from 'path'
import fetch from 'node-fetch'
const dir = resolve(import.meta.dirname, '.')
export const load = async url => {
const response = await fetch(url)
return response.ok ? response.text() : null
}
export const loadJSON = async url => {
const response = await fetch(url)
return response.ok ? response.json() : null
}
export const write = (name, data) => {
const dst = join(dir, name)
mkdirSync(dirname(dst), { recursive: true })
writeFileSync(dst, data)
}
export const writeJSON = (name, data) => write(`${name}.json`, JSON.stringify(data, null, 2))
const btcFormat = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'BTC' })
export const currency = code => {
switch (code) {
case 'USD':
return '$'
case 'EUR':
return '€'
default:
return code
}
}
export const sats2BTC = value => {
const btc = value/100000000
const formatted = btcFormat.format(btc)
return formatted.replace('BTC', '').replace(' ', '')
}

View file

@ -1,7 +1,7 @@
const { readFileSync } = require('fs')
const express = require('express')
const app = express()
const helpers = require('./helpers')
const helpers = require('./helpers.mjs')
const THEMES = ['quote', 'fees', 'lightning', 'stats']
const { DISPLAY_SERVER_PORT: port = 3030, DISPLAY_THEME: envTheme = THEMES[0] } = process.env
@ -9,7 +9,7 @@ app.set('view engine', 'pug')
app.use(express.static('public'))
app.get('/:theme?', (req, res) => {
app.get('/{:theme}', (req, res) => {
try {
const data = JSON.parse(readFileSync('data.json', 'utf8'))
const theme = (req.params.theme || envTheme).toLowerCase()

1766
server/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -12,11 +12,14 @@
"bugs": "https://github.com/dennisreimann/kindle-display/issues",
"main": "index.js",
"scripts": {
"start": "node -r dotenv/config index.js"
"start": "node -r dotenv/config index.js",
"data": "node data.mjs"
},
"dependencies": {
"dotenv": "16.3.1",
"express": "4.18.2",
"pug": "3.0.2"
"dotenv": "16.6.1",
"express": "5.2.1",
"json-2-csv": "5.5.10",
"node-fetch": "3.3.2",
"pug": "3.0.3"
}
}