mirror of
https://github.com/dennisreimann/kindle-display.git
synced 2026-08-13 12:33:45 +02:00
Upgrade dependencies
This commit is contained in:
parent
4447d290c2
commit
8f2ca99dbe
5 changed files with 846 additions and 995 deletions
|
|
@ -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
41
server/helpers.mjs
Normal 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(' ', '')
|
||||
}
|
||||
|
|
@ -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
1766
server/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue