@hyphen/sdk 1.6.0 → 1.8.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/README.md +42 -2
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
# Hyphen Node.js SDK
|
|
9
9
|
|
|
10
|
-
The Hyphen Node.js SDK is a JavaScript library that allows developers to easily integrate Hyphen's feature flag service [Toggle](https://hyphen.ai/toggle)
|
|
10
|
+
The Hyphen Node.js SDK is a JavaScript library that allows developers to easily integrate Hyphen's feature flag service [Toggle](https://hyphen.ai/toggle), secret management service [ENV](https://hyphen.ai/env), and geo information service [Net Info](https://hyphen.ai/net-info) into their Node.js applications.
|
|
11
11
|
|
|
12
12
|
# Table of Contents
|
|
13
13
|
- [Installation](#installation)
|
|
@@ -20,6 +20,9 @@ The Hyphen Node.js SDK is a JavaScript library that allows developers to easily
|
|
|
20
20
|
- [Toggle Caching](#toggle-caching)
|
|
21
21
|
- [Toggle Environment Variables](#toggle-environment-variables)
|
|
22
22
|
- [Toggle Self-Hosted](#toggle-self-hosted)
|
|
23
|
+
- [ENV](#env)
|
|
24
|
+
- [Loading Environment Variables](#loading-environment-variables)
|
|
25
|
+
- [Net Info](#net-info)
|
|
23
26
|
- [Contributing](#contributing)
|
|
24
27
|
- [Testing Your Changes](#testing-your-changes)
|
|
25
28
|
- [License and Copyright](#license-and-copyright)
|
|
@@ -529,6 +532,40 @@ import { loadEnv } from '@hyphen/sdk';
|
|
|
529
532
|
loadEnv({ local: false });
|
|
530
533
|
```
|
|
531
534
|
|
|
535
|
+
# Net Info
|
|
536
|
+
|
|
537
|
+
The Hyphen Node.js SDK also provides a `NetInfo` class that allows you to fetch geo information about an IP address. This can be useful for debugging or logging purposes. You can read more about it:
|
|
538
|
+
|
|
539
|
+
* [Website](https://hyphen.ai/net-info)
|
|
540
|
+
* [https://net.info](https://net.info) - webservice uri used by the SDK
|
|
541
|
+
* [Quick Start Guide](https://docs.hyphen.ai/docs/netinfo-quickstart)
|
|
542
|
+
|
|
543
|
+
To use the `NetInfo` class, you can do the following:
|
|
544
|
+
|
|
545
|
+
```javascript
|
|
546
|
+
import { NetInfo } from '@hyphen/sdk';
|
|
547
|
+
const netInfo = new NetInfo({
|
|
548
|
+
apiKey: 'your_api_key',
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
const ipInfo = await netInfo.getIpInfo('8.8.8.8');
|
|
552
|
+
console.log('IP Info:', ipInfo);
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
If you want to fetch information for multiple IP addresses, you can do it like this:
|
|
556
|
+
|
|
557
|
+
```javascript
|
|
558
|
+
import { NetInfo } from '@hyphen/sdk';
|
|
559
|
+
const netInfo = new NetInfo({
|
|
560
|
+
apiKey: 'your_api_key',
|
|
561
|
+
});
|
|
562
|
+
const ips = ['8.8.8.8', '1.1.1.1'];
|
|
563
|
+
const ipInfos = await netInfo.getIpInfos(ips);
|
|
564
|
+
console.log('IP Infos:', ipInfos);
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
You can also set the API key using the `HYPHEN_API_KEY` environment variable. This is useful for keeping your API key secure and not hardcoding it in your code.
|
|
568
|
+
|
|
532
569
|
# Contributing
|
|
533
570
|
|
|
534
571
|
We welcome contributions to the Hyphen Node.js SDK! If you have an idea for a new feature, bug fix, or improvement, please follow these steps:
|
|
@@ -566,10 +603,13 @@ Once you have created the project, added the toggles, and created your applicati
|
|
|
566
603
|
|
|
567
604
|
|
|
568
605
|
```bash
|
|
569
|
-
HYPHEN_PUBLIC_API_KEY=
|
|
606
|
+
HYPHEN_PUBLIC_API_KEY=your_public_api_key
|
|
607
|
+
HYPHEN_API_KEY=your_api_key
|
|
570
608
|
HYPHEN_APPLICATION_ID=your_project_id
|
|
571
609
|
```
|
|
572
610
|
|
|
611
|
+
The `HYPHEN_PUBLIC_API_KEY` is the public API key for your Hyphen project, `HYPHEN_API_KEY` is the API key used for things such as `NetInfo` and is located under settings in the dashboard, and `HYPHEN_APPLICATION_ID` is the application ID for your Hyphen project.
|
|
612
|
+
|
|
573
613
|
Then run the tests with the following command:
|
|
574
614
|
|
|
575
615
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyphen/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Hyphen SDK for Node.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -46,7 +46,10 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@hyphen/openfeature-server-provider": "^1.0.7",
|
|
48
48
|
"@openfeature/server-sdk": "^1.18.0",
|
|
49
|
+
"axios": "^1.10.0",
|
|
50
|
+
"cacheable": "^1.10.0",
|
|
49
51
|
"dotenv": "^16.5.0",
|
|
50
|
-
"hookified": "^1.9.0"
|
|
52
|
+
"hookified": "^1.9.0",
|
|
53
|
+
"pino": "^9.7.0"
|
|
51
54
|
}
|
|
52
55
|
}
|