The goal of this library is to provide a more intuitive and easy-to-understand way of using Nacos. Following the naming convention similar to simplify JSON.stringify and promisify, it is called Nacosify.
Design and implementation:
- Based on the official library, it provides a higher level of usability.
- Abstracts the namingClient and configClient into a single client.
- Places common capabilities at the first level and service and configuration-related capabilities at the second level.
- Simplifies function call parameters and standardizes parameter naming.
- Disables logging for health checks.
npm install nacosify
// or
yarn add nacosify
// or
pnpm add nacosify
For more usage examples, refer to example.js
.
import nacos form 'nacosify'
await nacos.init(addr, namespace, options={})
// registration
await nacos.register(appName, options={})
// deregistration
await nacos.deregister()
// graceful exit
await nacos.close()
// deregistration & graceful exit
await nacos.deregisterAndClose()
// get service
await nacos.service.get(name, group)
await nacos.service.getMore(names, group)
// subscribe to service
const reg = { name, group }
nacos.service.subscribe(reg, listener)
nacos.service.unSubscribe(reg, listener)
// get configuration
await nacos.config.get(id, group, options)
await nacos.config.getMore(ids, group, options)
// subscribe to configuration
const reg = { id, group }
nacos.config.subscribe(reg, listener)
nacos.config.unSubscribe(reg, listener)
- The parameters of the original official library can be directly passed through without conflicts.
- Installation dependencies may show some warnings about low package versions. This is due to the low dependency versions of the official library and does not affect usage.
Released under the MIT License.