currencyapi-node 1.1.1 → 1.2.0
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/.claude/settings.local.json +13 -0
- package/.github/workflows/tests.yml +4 -4
- package/CHANGELOG.md +20 -0
- package/Dockerfile +1 -1
- package/Makefile +7 -3
- package/README.md +9 -3
- package/package.json +4 -1
- package/run.js +24 -4
|
@@ -8,14 +8,14 @@ jobs:
|
|
|
8
8
|
|
|
9
9
|
strategy:
|
|
10
10
|
matrix:
|
|
11
|
-
node-version: [
|
|
11
|
+
node-version: [16.x, 18.x, 20.x, 22.x, 24.x]
|
|
12
12
|
|
|
13
13
|
steps:
|
|
14
14
|
- name: Checkout repository
|
|
15
|
-
uses: actions/checkout@
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
16
|
|
|
17
17
|
- name: Set up Node.js ${{ matrix.node-version }}
|
|
18
|
-
uses: actions/setup-node@
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
19
|
with:
|
|
20
20
|
node-version: ${{ matrix.node-version }}
|
|
21
21
|
|
|
@@ -26,4 +26,4 @@ jobs:
|
|
|
26
26
|
run: npm run test
|
|
27
27
|
|
|
28
28
|
- name: Upload coverage to Coveralls
|
|
29
|
-
uses: coverallsapp/github-action@v2
|
|
29
|
+
uses: coverallsapp/github-action@v2
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.2.0] - 2026-02-13
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Node.js v20, v22, and v24 support
|
|
9
|
+
- `engines` field in package.json specifying minimum Node.js version
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Dockerfile updated from Node 22 to Node 24
|
|
13
|
+
- CI matrix updated to test against Node.js 16, 18, 20, 22, and 24
|
|
14
|
+
- Updated GitHub Actions to latest versions (checkout@v4, setup-node@v4)
|
|
15
|
+
- Minimum supported Node.js version updated from v8 to v16
|
|
16
|
+
- README updated to reflect current Node.js compatibility
|
|
17
|
+
|
|
18
|
+
## [1.1.1] - Previous release
|
|
19
|
+
|
|
20
|
+
- Initial tracked version
|
package/Dockerfile
CHANGED
package/Makefile
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
.DEFAULT_GOAL := help
|
|
2
2
|
.PHONY: help
|
|
3
3
|
LOCAL_DOCKER_IMAGE=houseofapis/currencyapi-node
|
|
4
|
-
CONTAINER_NAME=currencyapi-node
|
|
4
|
+
CONTAINER_NAME=currencyapi-node-sdk
|
|
5
5
|
WORKING_DIR=/application
|
|
6
6
|
PORT=7003
|
|
7
|
-
DOCKER_COMMAND=docker run --rm -v ${PWD}:${WORKING_DIR} -w ${WORKING_DIR} --name ${CONTAINER_NAME} -p ${PORT}:${PORT}
|
|
7
|
+
DOCKER_COMMAND=docker run --rm -v ${PWD}:${WORKING_DIR} -w ${WORKING_DIR} --name ${CONTAINER_NAME} -p ${PORT}:${PORT} ${LOCAL_DOCKER_IMAGE}
|
|
8
|
+
DOCKER_COMMAND_INTERACTIVE=docker run --rm -v ${PWD}:${WORKING_DIR} -w ${WORKING_DIR} --name ${CONTAINER_NAME} -p ${PORT}:${PORT} -it ${LOCAL_DOCKER_IMAGE}
|
|
8
9
|
|
|
9
10
|
build: ## Build docker image
|
|
10
11
|
docker build -t ${LOCAL_DOCKER_IMAGE} . --no-cache
|
|
@@ -16,7 +17,10 @@ install: ## Npm install
|
|
|
16
17
|
${DOCKER_COMMAND} npm i
|
|
17
18
|
|
|
18
19
|
run: ## Run test file
|
|
19
|
-
${
|
|
20
|
+
${DOCKER_COMMAND_INTERACTIVE} node run.js
|
|
21
|
+
|
|
22
|
+
publish: ## Publish version (use: make publish OTP=123456 if 2FA enabled)
|
|
23
|
+
docker run --rm -v ${PWD}:${WORKING_DIR} -v ${HOME}/.npmrc:/home/node/.npmrc:ro -w ${WORKING_DIR} --name ${CONTAINER_NAME} ${LOCAL_DOCKER_IMAGE} npm publish $(if ${OTP},--otp=${OTP})
|
|
20
24
|
|
|
21
25
|
help:
|
|
22
26
|
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
package/README.md
CHANGED
|
@@ -17,14 +17,20 @@ Features:
|
|
|
17
17
|
|
|
18
18
|
Signup for a free or paid account <a href="https://currencyapi.net/#pricing-sec" title="currency-api-pricing">here</a>.
|
|
19
19
|
|
|
20
|
-
## This package
|
|
20
|
+
## This package is a:
|
|
21
21
|
|
|
22
22
|
NodeJs wrapper for <a href="https://currencyapi.net" title="CurrencyApi">CurrencyApi.net</a> endpoints.
|
|
23
23
|
|
|
24
|
+
## Developer Guide
|
|
25
|
+
|
|
26
|
+
For an easy to following developer guide, check out our [NodeJs Developer Guide](https://currencyapi.net/sdk/nodejs).
|
|
27
|
+
|
|
28
|
+
Alternatively keep reading below.
|
|
29
|
+
|
|
24
30
|
#### Prerequisites
|
|
25
31
|
|
|
26
|
-
- Minimum NodeJs
|
|
27
|
-
-
|
|
32
|
+
- Minimum NodeJs v16 (npm v7 and above)
|
|
33
|
+
- Tested on NodeJs v16, v18, v20, v22, v24
|
|
28
34
|
- Free or Paid account with CurrencyApi.net
|
|
29
35
|
|
|
30
36
|
#### Test Coverage
|
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
// run.js
|
|
2
|
+
const CurrencyApi = require('./src/CurrencyApi');
|
|
2
3
|
|
|
3
|
-
const currency = new CurrencyApi('
|
|
4
|
-
currency.rates().output('JSON').get()
|
|
5
|
-
.then(console.log)
|
|
4
|
+
const currency = new CurrencyApi('YOUR_API_KEY');
|
|
6
5
|
|
|
6
|
+
async function convertCurrency(amount, fromCurrency, toCurrency) {
|
|
7
|
+
try {
|
|
8
|
+
const result = await currency.convert()
|
|
9
|
+
.from(fromCurrency)
|
|
10
|
+
.to(toCurrency)
|
|
11
|
+
.amount(amount)
|
|
12
|
+
.get();
|
|
13
|
+
return result.conversion.result;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
throw new Error(`Conversion failed: ${error.message}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
(async () => {
|
|
20
|
+
try {
|
|
21
|
+
const converted = await convertCurrency(100, 'BTC', 'USD');
|
|
22
|
+
console.log(`100 BTC is equal to ${converted} USD`);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error(error);
|
|
25
|
+
}
|
|
26
|
+
})();
|