{"_id":"@dalongrong/nacos-naming","name":"@dalongrong/nacos-naming","dist-tags":{"latest":"2.6.2"},"versions":{"2.6.2":{"name":"@dalongrong/nacos-naming","version":"2.6.2","description":"nacos (https://nacos.io/en-us/) nodejs sdk","main":"index.js","scripts":{"autod":"autod","lint":"eslint . --ext .js","cov":"TEST_TIMEOUT=20000 egg-bin cov","test":"npm run lint && npm run test-local","test-local":"egg-bin test","pkgfiles":"egg-bin pkgfiles --check","ci":"npm run autod -- --check && npm run pkgfiles && npm run lint && npm run cov","contributors":"contributors -f plain -o AUTHORS"},"publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"repository":{"type":"git","url":"git+https://github.com/nacos-group/nacos-sdk-nodejs.git"},"keywords":["nacos","cloud","native","eggjs"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"Apache","bugs":{"url":"https://github.com/nacos-group/nacos-sdk-nodejs/issues"},"homepage":"https://github.com/nacos-group/nacos-sdk-nodejs#readme","engines":{"node":">= 8.0.0"},"ci":{"type":"travis","version":"8, 10, 12"},"dependencies":{"address":"^1.1.0","equals":"^1.0.5","mz-modules":"^2.1.0","sdk-base":"^3.6.0","urllib":"^2.33.3","utility":"^1.16.1","uuid":"^3.3.2"},"devDependencies":{"autod":"^3.1.0","await-event":"^2.1.0","contributors":"^0.5.1","egg-bin":"^4.13.1","egg-ci":"^1.11.0","eslint":"^5.16.0","eslint-config-egg":"^7.3.1","mm":"^2.5.0","mz-modules":"^2.1.0"},"gitHead":"eb009bdaa5949d4f90e18c6eacf66d6dcf907c96","_id":"@dalongrong/nacos-naming@2.6.2","_nodeVersion":"19.9.0","_npmVersion":"lerna/3.22.1/node@v19.9.0+x64 (darwin)","dist":{"integrity":"sha512-OSc/KN3RA9qfmOg/xzdYrrzmVDwFhMN6dHcUaLbMXf9uD8ByUtKcbqvNgMxJrHpa9okgozassxGMlctB4PoS9w==","shasum":"946f917092d0e5f96d638dfc74283b449b3d770d","tarball":"https://registry.npmjs.org/@dalongrong/nacos-naming/-/nacos-naming-2.6.2.tgz","fileCount":15,"unpackedSize":61029,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCzW/ljZdasK2uo98TPnnjbVpbQkGcakGohYkPUX7KUJwIhAPOfdImnF3f/5o212f0OjgM/ebYUNAb8cLcw4zluTNHn"}]},"_npmUser":{"name":"dalongrong","email":"1141591465@qq.com"},"directories":{},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nacos-naming_2.6.2_1746350509031_0.7790328016287369"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-04T09:21:48.970Z","2.6.2":"2025-05-04T09:21:49.248Z","modified":"2025-05-04T09:21:49.580Z"},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"description":"nacos (https://nacos.io/en-us/) nodejs sdk","homepage":"https://github.com/nacos-group/nacos-sdk-nodejs#readme","keywords":["nacos","cloud","native","eggjs"],"repository":{"type":"git","url":"git+https://github.com/nacos-group/nacos-sdk-nodejs.git"},"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"bugs":{"url":"https://github.com/nacos-group/nacos-sdk-nodejs/issues"},"license":"Apache","readme":"# nacos-sdk-nodejs\n=======\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![David deps][david-image]][david-url]\n\n[npm-image]: https://img.shields.io/npm/v/ali-ons.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/ali-ons\n[travis-image]: https://img.shields.io/travis/ali-sdk/ali-ons.svg?style=flat-square\n[travis-url]: https://travis-ci.org/ali-sdk/ali-ons\n[david-image]: https://img.shields.io/david/ali-sdk/ali-ons.svg?style=flat-square\n[david-url]: https://david-dm.org/ali-sdk/ali-ons\n\n\n[Nacos](https://nacos.io/en-us/) Node.js SDK\n\n## Install\n\n```bash\nnpm install nacos --save\n```\n\n## Usage\n\n### Service Discovery\n\n```js\n'use strict';\n\nconst NacosNamingClient = require('nacos').NacosNamingClient;\nconst logger = console;\n\nconst client = new NacosNamingClient({\n  logger,\n  serverList: '127.0.0.1:8848', // replace to real nacos serverList\n  namespace: 'public',\n});\nawait client.ready();\n\nconst serviceName = 'nodejs.test.domain';\n\n// registry instance\nawait client.registerInstance(serviceName, {\n  ip: '1.1.1.1',\n  port: 8080,\n});\nawait client.registerInstance(serviceName, {\n  ip: '2.2.2.2',\n  port: 8080,\n});\n\n// subscribe instance\nclient.subscribe(serviceName, hosts => {\n  console.log(hosts);\n});\n\n// deregister instance\nawait client.deregisterInstance(serviceName, {\n  ip: '1.1.1.1',\n  port: 8080,\n});\n```\n\n## APIs\n\n### Service Discovery\n\n- `registerInstance(serviceName, instance, [groupName])`  Register an instance to service.\n  - serviceName {String} Service name\n  - instance {Instance}\n    - ip {String} IP of instance\n    - port {Number} Port of instance\n    - [weight] {Number} weight of the instance, default is 1.0\n    - [ephemeral] {Boolean} active until the client is alive, default is true\n    - [clusterName] {String} Virtual cluster name\n  - [groupName] {String} group name, default is `DEFAULT_GROUP`\n- `deregisterInstance(serviceName, ip, port, [cluster])`  Delete instance from service.\n  - serviceName {String} Service name\n  - instance {Instance}\n    - ip {String} IP of instance\n    - port {Number} Port of instance\n    - [weight] {Number} weight of the instance, default is 1.0\n    - [ephemeral] {Boolean} active until the client is alive, default is true\n    - [clusterName] {String} Virtual cluster name\n  - [groupName] {String} group name, default is `DEFAULT_GROUP`\n- `getAllInstances(serviceName, [groupName], [clusters], [subscribe])`  Query instance list of service.\n  - serviceName {String} Service name\n  - [groupName] {String} group name, default is `DEFAULT_GROUP`\n  - [clusters] {String} Cluster names\n  - [subscribe] {Boolean} whether subscribe the service, default is true\n- `getServerStatus()` Get the status of nacos server, 'UP' or 'DOWN'.\n- `subscribe(info, listener)` Subscribe the instances of the service\n  - info {Object}|{String} service info, if type is string, it's the serviceName\n  - listener {Function} the listener function\n- `unSubscribe(info, [listener])` Unsubscribe the instances of the service\n  - info {Object}|{String} service info, if type is string, it's the serviceName\n  - listener {Function} the listener function, if not provide, will unSubscribe all listeners under this service\n\n## Questions & Suggestions\n\nPlease let us know how can we help. Do check out [issues](https://github.com/nacos-group/nacos-sdk-nodejs/issues) for bug reports or suggestions first.\n\nPR is welcome.\n\n## License\n\n[Apache License V2](LICENSE)\n","readmeFilename":"README.md","_rev":"1-3433108a9238525055d8e33d63d0d9e4"}