xchange-rates 1.0.0 → 2025.8.16-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const fetch = require('node-fetch');
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import fetch from 'node-fetch';
4
4
 
5
5
  const localPath = path.resolve('./v1/currencies.json');
6
6
  let localRates = fs.existsSync(localPath) ? JSON.parse(fs.readFileSync(localPath, 'utf-8')) : null;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "xchange-rates",
3
- "version": "1.0.0",
3
+ "version": "2025.8.16-1",
4
4
  "description": "A lightweight Node.js package to get real-time currency exchange rates for any base currency using a pivot currency, fetched directly from a CDN for fast and reliable access.",
5
5
  "main": "index.js",
6
+ "type": "module",
6
7
  "scripts": {
7
8
  "update": "node scripts/updateRates.js",
8
9
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,179 @@
1
+ {
2
+ "timestamp": 1755331205,
3
+ "base": "USD",
4
+ "rates": {
5
+ "AED": 3.67295,
6
+ "AFN": 69,
7
+ "ALL": 83.8,
8
+ "AMD": 383.1,
9
+ "ANG": 1.79,
10
+ "AOA": 917,
11
+ "ARS": 1297.537602,
12
+ "AUD": 1.537043,
13
+ "AWG": 1.80075,
14
+ "AZN": 1.7,
15
+ "BAM": 1.673054,
16
+ "BBD": 2,
17
+ "BDT": 121.454217,
18
+ "BGN": 1.67146,
19
+ "BHD": 0.376789,
20
+ "BIF": 2960,
21
+ "BMD": 1,
22
+ "BND": 1.281694,
23
+ "BOB": 6.907525,
24
+ "BRL": 5.4013,
25
+ "BSD": 1,
26
+ "BTC": 0.000008496902,
27
+ "BTN": 87.426851,
28
+ "BWP": 13.378101,
29
+ "BYN": 3.323768,
30
+ "BZD": 2.00793,
31
+ "CAD": 1.38215,
32
+ "CDF": 2895,
33
+ "CHF": 0.806593,
34
+ "CLF": 0.024586,
35
+ "CLP": 963.17,
36
+ "CNH": 7.1854,
37
+ "CNY": 7.1821,
38
+ "COP": 4046.904675,
39
+ "CRC": 505.848441,
40
+ "CUC": 1,
41
+ "CUP": 25.75,
42
+ "CVE": 94.9,
43
+ "CZK": 20.9044,
44
+ "DJF": 177.827972,
45
+ "DKK": 6.37675,
46
+ "DOP": 61.725,
47
+ "DZD": 129.567225,
48
+ "EGP": 48.265049,
49
+ "ERN": 15,
50
+ "ETB": 141.15,
51
+ "EUR": 0.854348,
52
+ "FJD": 2.2559,
53
+ "FKP": 0.73749,
54
+ "GBP": 0.73749,
55
+ "GEL": 2.69,
56
+ "GGP": 0.73749,
57
+ "GHS": 10.65,
58
+ "GIP": 0.73749,
59
+ "GMD": 72.499999,
60
+ "GNF": 8677.5,
61
+ "GTQ": 7.667237,
62
+ "GYD": 209.056268,
63
+ "HKD": 7.82445,
64
+ "HNL": 26.4,
65
+ "HRK": 6.43702,
66
+ "HTG": 130.80408,
67
+ "HUF": 337.8,
68
+ "IDR": 16203,
69
+ "ILS": 3.37948,
70
+ "IMP": 0.73749,
71
+ "INR": 87.51385,
72
+ "IQD": 1310,
73
+ "IRR": 42125,
74
+ "ISK": 122.38,
75
+ "JEP": 0.73749,
76
+ "JMD": 159.957172,
77
+ "JOD": 0.709,
78
+ "JPY": 147.09494849,
79
+ "KES": 129.5,
80
+ "KGS": 87.3788,
81
+ "KHR": 4005,
82
+ "KMF": 420.499968,
83
+ "KPW": 900,
84
+ "KRW": 1388.97,
85
+ "KWD": 0.305303,
86
+ "KYD": 0.83302,
87
+ "KZT": 541.496827,
88
+ "LAK": 21600,
89
+ "LBP": 89552.5,
90
+ "LKR": 300.889726,
91
+ "LRD": 201.499983,
92
+ "LSL": 17.59,
93
+ "LYD": 5.415,
94
+ "MAD": 9.0095,
95
+ "MDL": 16.598984,
96
+ "MGA": 4440,
97
+ "MKD": 52.634726,
98
+ "MMK": 2099,
99
+ "MNT": 3592.646,
100
+ "MOP": 8.081343,
101
+ "MRU": 39.95,
102
+ "MUR": 45.520003,
103
+ "MVR": 15.4,
104
+ "MWK": 1735,
105
+ "MXN": 18.7435,
106
+ "MYR": 4.213,
107
+ "MZN": 63.959999,
108
+ "NAD": 17.59,
109
+ "NGN": 1532.72,
110
+ "NIO": 36.76,
111
+ "NOK": 10.19562,
112
+ "NPR": 139.882797,
113
+ "NZD": 1.688049,
114
+ "OMR": 0.384284,
115
+ "PAB": 1,
116
+ "PEN": 3.56,
117
+ "PGK": 4.14,
118
+ "PHP": 57.107006,
119
+ "PKR": 282.05,
120
+ "PLN": 3.638739,
121
+ "PYG": 7492.814679,
122
+ "QAR": 3.6406,
123
+ "RON": 4.3258,
124
+ "RSD": 100.188013,
125
+ "RUB": 80.100406,
126
+ "RWF": 1445,
127
+ "SAR": 3.752253,
128
+ "SBD": 8.223773,
129
+ "SCR": 14.145453,
130
+ "SDG": 600.5,
131
+ "SEK": 9.5588,
132
+ "SGD": 1.282874,
133
+ "SHP": 0.73749,
134
+ "SLE": 23.225,
135
+ "SLL": 20969.5,
136
+ "SOS": 571.5,
137
+ "SRD": 37.56,
138
+ "SSP": 130.26,
139
+ "STD": 22281.8,
140
+ "STN": 21.3,
141
+ "SVC": 8.746792,
142
+ "SYP": 13002,
143
+ "SZL": 17.59,
144
+ "THB": 32.420657,
145
+ "TJS": 9.321609,
146
+ "TMT": 3.51,
147
+ "TND": 2.921557,
148
+ "TOP": 2.40776,
149
+ "TRY": 40.799999,
150
+ "TTD": 6.782633,
151
+ "TWD": 30.0325,
152
+ "TZS": 2611.496551,
153
+ "UAH": 41.258598,
154
+ "UGX": 3558.612919,
155
+ "USD": 1,
156
+ "UYU": 40.070284,
157
+ "UZS": 12550,
158
+ "VES": 135.470356,
159
+ "VND": 26270.889205,
160
+ "VUV": 119.1167,
161
+ "WST": 2.7716,
162
+ "XAF": 560.415306,
163
+ "XAG": 0.02631337,
164
+ "XAU": 0.00029985,
165
+ "XCD": 2.70255,
166
+ "XCG": 1.801625,
167
+ "XDR": 0.704914,
168
+ "XOF": 560.415306,
169
+ "XPD": 0.00089865,
170
+ "XPF": 101.950791,
171
+ "XPT": 0.0007475,
172
+ "YER": 240.27495,
173
+ "ZAR": 17.595245,
174
+ "ZMW": 23.166511,
175
+ "ZWG": 26.78,
176
+ "ZWL": 322
177
+ },
178
+ "date": "2025-08-16"
179
+ }
@@ -1,36 +0,0 @@
1
- name: Publish Exchange Rates
2
-
3
- on:
4
- schedule:
5
- - cron: '0 0 * * *' # daily at midnight UTC
6
- workflow_dispatch:
7
-
8
- jobs:
9
- update:
10
- runs-on: ubuntu-latest
11
-
12
- steps:
13
- - uses: actions/checkout@v4
14
-
15
- - uses: actions/setup-node@v4
16
- with:
17
- node-version: 18
18
- registry-url: 'https://registry.npmjs.org'
19
-
20
- - name: Install dependencies
21
- run: npm install
22
-
23
- - name: Update exchange rates
24
- run: npm run update
25
- env:
26
- XCR_KEY1: ${{ secrets.XCR_KEY1 }}
27
- XCR_URL1: ${{ secrets.XCR_URL1 }}
28
-
29
- - name: Package and publish to npm
30
- run: |
31
- mkdir package
32
- cp -r package.json index.js v1 package/
33
- cd package
34
- npm publish --access public
35
- env:
36
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,37 +0,0 @@
1
- const fs = require('fs');
2
- const fetch = require('node-fetch');
3
- const dotenv = require('dotenv');
4
- const { format } = require('date-fns');
5
- const path = require('path');
6
-
7
-
8
- dotenv.config();
9
-
10
- const KEY = process.env.XCR_KEY1;
11
- const URL = process.env.XCR_URL1;
12
- const API_URL = `${URL}${APP_ID}`;
13
- const outputDir = path.resolve('./v1');
14
- const outputFile = path.join(outputDir, 'currencies.json');
15
-
16
- async function updateRates() {
17
- try {
18
- const res = await fetch(API_URL);
19
- const data = await res.json();
20
-
21
- // Remove disclaimer and license
22
- const { disclaimer, license, ...cleanData } = data;
23
-
24
- // Add today's date
25
- cleanData.date = format(new Date(), 'yyyy-MM-dd');
26
-
27
- // Ensure directory exists
28
- if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir);
29
-
30
- fs.writeFileSync(outputFile, JSON.stringify(cleanData, null, 2));
31
- console.log('Exchange rates updated successfully!');
32
- } catch (err) {
33
- console.error('Error updating rates:', err);
34
- }
35
- }
36
-
37
- updateRates();