@danqiusheng/nest-nacos 1.0.0 → 1.1.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/CHANGELOG.md +14 -0
- package/LICENSE +21 -21
- package/README.en.md +59 -0
- package/README.md +78 -457
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/nacos-config.service.d.ts +25 -45
- package/dist/nacos-config.service.d.ts.map +1 -1
- package/dist/nacos-config.service.js +241 -102
- package/dist/nacos-config.service.js.map +1 -1
- package/dist/nacos-naming.service.d.ts +16 -46
- package/dist/nacos-naming.service.d.ts.map +1 -1
- package/dist/nacos-naming.service.js +119 -88
- package/dist/nacos-naming.service.js.map +1 -1
- package/dist/nacos.decorators.d.ts +0 -4
- package/dist/nacos.decorators.d.ts.map +1 -1
- package/dist/nacos.decorators.js +1 -12
- package/dist/nacos.decorators.js.map +1 -1
- package/dist/nacos.health.d.ts +2 -6
- package/dist/nacos.health.d.ts.map +1 -1
- package/dist/nacos.health.js +5 -25
- package/dist/nacos.health.js.map +1 -1
- package/dist/nacos.interfaces.d.ts +68 -55
- package/dist/nacos.interfaces.d.ts.map +1 -1
- package/dist/nacos.module.d.ts +0 -9
- package/dist/nacos.module.d.ts.map +1 -1
- package/dist/nacos.module.js +20 -17
- package/dist/nacos.module.js.map +1 -1
- package/dist/nacos.providers.d.ts +1 -10
- package/dist/nacos.providers.d.ts.map +1 -1
- package/dist/nacos.providers.js +12 -23
- package/dist/nacos.providers.js.map +1 -1
- package/dist/nacos.utils.d.ts +6 -0
- package/dist/nacos.utils.d.ts.map +1 -0
- package/dist/nacos.utils.js +79 -0
- package/dist/nacos.utils.js.map +1 -0
- package/package.json +17 -10
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
- Fix asynchronous server status and health checks.
|
|
6
|
+
- Fix duplicate Config callbacks and SDK listener identity during unsubscribe.
|
|
7
|
+
- Fix Naming unsubscribe-all behavior.
|
|
8
|
+
- Close both SDK clients during module shutdown.
|
|
9
|
+
- Fix `forRootAsync({ useClass })` and export raw client tokens.
|
|
10
|
+
- Normalize the public Config namespace to the empty namespace ID.
|
|
11
|
+
- Add JSON, YAML, Properties and TXT parsing, preload merge, hot-update state,
|
|
12
|
+
local fallback cache, startup failure modes and retries.
|
|
13
|
+
- Add random, round-robin and weighted discovery with metadata filtering.
|
|
14
|
+
- Remove false Nacos 3.x and gRPC compatibility claims.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 丹丘生
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 丹丘生
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @danqiusheng/nest-nacos
|
|
2
|
+
|
|
3
|
+
Nacos 2.x configuration and service-discovery integration for NestJS 10/11.
|
|
4
|
+
|
|
5
|
+
## Compatibility
|
|
6
|
+
|
|
7
|
+
| Component | Supported |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Node.js | >= 16 |
|
|
10
|
+
| NestJS | 10.x, 11.x |
|
|
11
|
+
| Nacos Node SDK | `nacos` 2.6.x |
|
|
12
|
+
| Nacos Server | 2.x; end-to-end tested against 2.5.3 |
|
|
13
|
+
| Nacos Server 3.x / gRPC | Not supported |
|
|
14
|
+
|
|
15
|
+
The underlying SDK only implements the legacy HTTP OpenAPI. The plugin rejects
|
|
16
|
+
`transport: 'grpc'` instead of silently claiming a transport it does not use.
|
|
17
|
+
The Nest application does not require Java. Java is only needed when running a
|
|
18
|
+
Nacos Server locally.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @danqiusheng/nest-nacos nacos
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
NacosModule.forRoot({
|
|
30
|
+
config: { serverAddr: '127.0.0.1:8848', namespace: 'public' },
|
|
31
|
+
naming: { serverList: '127.0.0.1:8848', namespace: 'public' },
|
|
32
|
+
instances: [{ serviceName: 'api', ip: '10.0.0.5', port: 3000 }],
|
|
33
|
+
subscribeConfigs: [
|
|
34
|
+
{ dataId: 'application.yaml', format: 'yaml' },
|
|
35
|
+
{ dataId: 'database.properties', format: 'properties' },
|
|
36
|
+
],
|
|
37
|
+
configLoading: {
|
|
38
|
+
failureMode: 'fallback',
|
|
39
|
+
cacheDir: '.nacos-cache',
|
|
40
|
+
retry: { attempts: 3, delayMs: 300 },
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Configuration features include JSON, YAML, Properties and text parsing, deep
|
|
46
|
+
merge, hot updates, one SDK subscription per key, local fallback files and
|
|
47
|
+
configurable startup behavior. Naming supports random, round-robin and weighted
|
|
48
|
+
selection with metadata filters.
|
|
49
|
+
|
|
50
|
+
Both health APIs are asynchronous:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
await naming.getServerStatus();
|
|
54
|
+
await healthIndicator.isHealthy();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Run `npm run build && npm test` for deterministic regressions. Release validation
|
|
58
|
+
must additionally use a real Nacos 2.x server and verify writes through the
|
|
59
|
+
server API.
|