node-consul-service 1.0.8 → 1.0.10

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.
Files changed (2) hide show
  1. package/README.md +43 -116
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,135 +1,62 @@
1
- # Node Consul Service | خدمة نود كونسول
1
+ # Node Consul Service
2
2
 
3
- [English](#english) | [العربية](#arabic)
4
-
5
- ## English
6
-
7
- ### Overview
8
3
  A Node.js service that integrates with HashiCorp Consul for service discovery and configuration management. This service provides a robust solution for managing distributed systems and microservices architecture.
9
4
 
10
5
  ### Features
11
6
  - Service registration and discovery
12
7
  - Health checking
13
- - Key-value store integration
14
- - Configuration management
15
- - Distributed locking
16
- - Leader election
8
+ - Service communication
9
+ - Service instance management
17
10
 
18
11
  ### Prerequisites
19
12
  - Node.js (v14 or higher)
20
13
  - Consul server
21
- - npm or yarn
14
+ - npm
22
15
 
23
16
  ### Installation
24
17
  ```bash
25
- # Clone the repository
26
- git clone https://github.com/your-username/node-consul-service.git
27
-
28
- # Navigate to project directory
29
- cd node-consul-service
30
-
31
- # Install dependencies
32
- npm install
18
+ npm install node-consul-service
33
19
  ```
34
20
 
35
- ### Configuration
36
- Create a `.env` file in the root directory with the following variables:
37
- ```env
38
- CONSUL_HOST=localhost
39
- CONSUL_PORT=8500
40
- SERVICE_NAME=my-service
41
- SERVICE_PORT=3000
42
- ```
43
-
44
- ### Usage
45
- ```bash
46
- # Start the service
47
- npm start
48
-
49
- # Run tests
50
- npm test
21
+ ### Function Usage
22
+ Here are the main functions available in the service:
23
+
24
+ ```javascript
25
+ const {
26
+ registerService,
27
+ callService,
28
+ listServices,
29
+ getServiceInstances,
30
+ getRandomServiceInstance
31
+ } = require('node-consul-service');
32
+
33
+ // Register a new service
34
+ await registerService({
35
+ name: 'service-name',
36
+ id: 'service-id',
37
+ port: 3000,
38
+ address: 'localhost',
39
+ check: {
40
+ name: 'service health check',
41
+ http: 'http://localhost:3000/health',
42
+ interval: '10s',
43
+ timeout: '5s',
44
+ deregistercriticalserviceafter: '1m'
45
+ }
46
+ });
47
+
48
+ // Call another service
49
+ const result = await callService('service-name', '/endpoint');
50
+
51
+ // List all registered services
52
+ const services = await listServices();
53
+
54
+ // Get all instances of a specific service
55
+ const instances = await getServiceInstances('service-name');
56
+
57
+ // Get a random instance of a service
58
+ const instance = await getRandomServiceInstance('service-name');
51
59
  ```
52
60
 
53
- ### API Documentation
54
- The service exposes the following endpoints:
55
- - `GET /health` - Health check endpoint
56
- - `GET /services` - List registered services
57
- - `POST /register` - Register a new service
58
- - `DELETE /deregister` - Deregister a service
59
-
60
- ### Contributing
61
- 1. Fork the repository
62
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
63
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
64
- 4. Push to the branch (`git push origin feature/amazing-feature`)
65
- 5. Open a Pull Request
66
-
67
61
  ### License
68
62
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
69
-
70
- ---
71
-
72
- ## Arabic
73
-
74
- ### نظرة عامة
75
- خدمة Node.js تتكامل مع HashiCorp Consul لاكتشاف الخدمات وإدارة التكوين. توفر هذه الخدمة حلاً قوياً لإدارة الأنظمة الموزعة وهندسة الخدمات المصغرة.
76
-
77
- ### المميزات
78
- - تسجيل واكتشاف الخدمات
79
- - فحص الصحة
80
- - تكامل مع مخزن القيم المفتاحية
81
- - إدارة التكوين
82
- - القفل الموزع
83
- - انتخاب القائد
84
-
85
- ### المتطلبات الأساسية
86
- - Node.js (الإصدار 14 أو أحدث)
87
- - خادم Consul
88
- - npm أو yarn
89
-
90
- ### التثبيت
91
- ```bash
92
- # استنساخ المستودع
93
- git clone https://github.com/your-username/node-consul-service.git
94
-
95
- # الانتقال إلى مجلد المشروع
96
- cd node-consul-service
97
-
98
- # تثبيت التبعيات
99
- npm install
100
- ```
101
-
102
- ### التكوين
103
- قم بإنشاء ملف `.env` في المجلد الرئيسي مع المتغيرات التالية:
104
- ```env
105
- CONSUL_HOST=localhost
106
- CONSUL_PORT=8500
107
- SERVICE_NAME=my-service
108
- SERVICE_PORT=3000
109
- ```
110
-
111
- ### الاستخدام
112
- ```bash
113
- # تشغيل الخدمة
114
- npm start
115
-
116
- # تشغيل الاختبارات
117
- npm test
118
- ```
119
-
120
- ### توثيق API
121
- تعرض الخدمة النقاط النهائية التالية:
122
- - `GET /health` - نقطة نهاية فحص الصحة
123
- - `GET /services` - قائمة الخدمات المسجلة
124
- - `POST /register` - تسجيل خدمة جديدة
125
- - `DELETE /deregister` - إلغاء تسجيل خدمة
126
-
127
- ### المساهمة
128
- 1. قم بعمل fork للمستودع
129
- 2. أنشئ فرع الميزة الخاص بك (`git checkout -b feature/amazing-feature`)
130
- 3. قم بعمل commit للتغييرات (`git commit -m 'Add some amazing feature'`)
131
- 4. ادفع إلى الفرع (`git push origin feature/amazing-feature`)
132
- 5. افتح طلب سحب (Pull Request)
133
-
134
- ### الترخيص
135
- هذا المشروع مرخص تحت رخصة MIT - راجع ملف [LICENSE](LICENSE) للتفاصيل.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-consul-service",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",