diff --git a/bin/build-coinbase.mjs b/bin/build-coinbase.mjs index bab6e8c..493f5df 100644 --- a/bin/build-coinbase.mjs +++ b/bin/build-coinbase.mjs @@ -2,12 +2,9 @@ import { createReadStream, createWriteStream } from 'node:fs' import { mkdir } from 'node:fs/promises' - import { readCache, byExchange } from '../lib/cache.mjs' - import { fromJsonl as jsonlToCsv } from '../lib/stream/csv.mjs' import { fromJsonl as jsonlToJson } from '../lib/stream/json.mjs' -import { fromJsonl as jsonlToXml } from '../lib/stream/xml.mjs' for (const file of await readCache(byExchange('coinbase'))) { console.log('► bin/build-coinbase loading:%s', file) @@ -28,9 +25,4 @@ for (const file of await readCache(byExchange('coinbase'))) { jsonlToJson(createReadStream(file)) .pipe(createWriteStream(`www/api/${id}/${interval}.json`)) .on('close', () => console.timeEnd(`◄ bin/build-coinbase created: ${file} ➡️ www/api/${id}/${interval}.json elapsed`)) - // xml - console.time(`◄ bin/build-coinbase created: ${file} ➡️ www/api/${id}/${interval}.xml elapsed`) - jsonlToXml(createReadStream(file)) - .pipe(createWriteStream(`www/api/${id}/${interval}.xml`)) - .on('close', () => console.timeEnd(`◄ bin/build-coinbase created: ${file} ➡️ www/api/${id}/${interval}.xml elapsed`)) } diff --git a/lib/stream/xml.mjs b/lib/stream/xml.mjs deleted file mode 100644 index db61a21..0000000 --- a/lib/stream/xml.mjs +++ /dev/null @@ -1,32 +0,0 @@ -import fs from 'node:fs' -import readline from 'node:readline' -import stream from 'node:stream' -import os from 'node:os' -import { jsonDateReviver } from '../date.mjs' - -export function fromJsonl (input, { createReadStream } = fs, { createInterface } = readline, { Readable } = stream) { - const xml = new Readable({ objectMode: false, read () {} }) - xml.setEncoding('utf8') - xml.push(header()) - createInterface({ input, terminal: false, crlfDelay: Infinity }) - .on('line', buffer => xml.push(toXML(buffer))) - .on('close', () => { - xml.push(footer()) - xml.push(null) - }) - - return xml -} - -export function header ({ EOL } = os) { - return `${EOL}${EOL}${EOL}` -} - -export function footer ({ EOL } = os) { - return `${EOL}` -} - -export function toXML (line, { EOL } = os) { - const [date, open, high, low, close, volume] = JSON.parse(line, jsonDateReviver) - return `\t${EOL}\t\t${date.toJSON().substr(0, 10)}${EOL}\t\t${open}${EOL}\t\t${high}${EOL}\t\t${low}${EOL}\t\t${close}${EOL}\t\t${volume}${EOL}\t${EOL}` -} diff --git a/www/api/openapi.json b/www/api/openapi.json index 951eda2..57a0d83 100644 --- a/www/api/openapi.json +++ b/www/api/openapi.json @@ -62,7 +62,6 @@ "type": "string", "enum": [ "csv", - "xml", "json" ] }, @@ -132,7 +131,6 @@ "type": "string", "enum": [ "csv", - "xml", "json" ] }, @@ -211,7 +209,6 @@ "type": "string", "enum": [ "csv", - "xml", "json" ] }, @@ -263,7 +260,6 @@ "type": "string", "enum": [ "csv", - "xml", "json" ] }, @@ -280,7 +276,6 @@ "description": "Successful response", "content": { "application/json": {}, - "application/xml": {}, "text/csv": { "schema": { "type": "array",