Skip to content

Commit bb81db0

Browse files
committed
修改readme
1 parent 1402e71 commit bb81db0

9 files changed

Lines changed: 194 additions & 214 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
- name: Setup Node.js
1717
uses: actions/setup-node@v4
1818
with:
19-
node-version: 20
19+
node-version: 18
2020

2121
- name: Setup pnpm
2222
uses: pnpm/action-setup@v2
2323
with:
24-
version: 8
24+
version: 9
2525

2626
- name: Install Dependencies
2727
run: pnpm install

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020
- name: Setup Node.js
2121
uses: actions/setup-node@v4
2222
with:
23-
node-version: 20
23+
node-version: 18
2424

2525
- name: Setup pnpm
2626
uses: pnpm/action-setup@v2
2727
with:
28-
version: 8
28+
version: 9
2929

3030
- name: Install Dependencies
3131
run: pnpm install

README.EN.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ English | [中文](README.md)
22

33
# Volcengine SDK for Node.js
44

5-
## Installation
5+
## Installation Core Packages
66

77
### Requirements
88

@@ -35,34 +35,26 @@ export VOLCSTACK_ACCESS_KEY_ID="YOUR_AK"
3535
export VOLCSTACK_SECRET_ACCESS_KEY="YOUR_SK"
3636
```
3737

38-
## Endpoint Configuration
39-
40-
The SDK supports multiple ways to configure the Endpoint, with the following priority (highest to lowest):
41-
42-
1. **Custom Endpoint**: Specify `EndpointWithEndpoint` in the client configuration (e.g. `iam.example.com`).
43-
2. **Automatic Addressing**: Specify `region`, and the SDK will automatically construct the Endpoint based on the service name and region (e.g. `ecs.cn-beijing.volcengineapi.com`).
44-
3. **Default**: If not specified and cannot be deduced, `open.volcengineapi.com` is used by default.
45-
4638
## Quick Start
4739

4840
The following example shows how to initialize the client and send a request.
49-
Install the corresponding service SDK package (e.g., `@volcengine/iam`).
41+
Install the corresponding service SDK package (e.g., `@volcengine/ecs`).
5042

5143
```bash
5244
# pnpm
53-
pnpm add @volcengine/iam
45+
pnpm add @volcengine/ecs
5446
```
5547

5648
```typescript
57-
import { IAMClient, ListUsersCommand } from "@volcengine/iam"; // Need to install the corresponding service package
49+
import { ECSClient, DescribeZonesCommand } from "@volcengine/ecs"; // Need to install the corresponding service package
5850

5951
// 1. Use AK/SK from environment variables and specify Region
60-
const client = new IAMClient({
52+
const client = new ECSClient({
6153
region: "cn-beijing",
6254
});
6355

6456
// 2. Or explicitly pass AK/SK in the code
65-
// const client = new IAMClient({
57+
// const client = new ECSClient({
6658
// accessKeyId: "YOUR_AK",
6759
// secretAccessKey: "YOUR_SK",
6860
// region: "cn-beijing",
@@ -71,7 +63,7 @@ const client = new IAMClient({
7163
async function main() {
7264
try {
7365
// Send request (refer to service SDK documentation for specific Commands)
74-
const command = new ListUsersCommand({});
66+
const command = new DescribeZonesCommand({});
7567
const response = await client.send(command);
7668
console.log(response);
7769
} catch (error) {

README.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Volcengine SDK for Node.js
44

5-
## 安装
5+
## 安装 Core 包
66

77
### 环境要求
88

@@ -35,35 +35,27 @@ export VOLCSTACK_ACCESS_KEY_ID="YOUR_AK"
3535
export VOLCSTACK_SECRET_ACCESS_KEY="YOUR_SK"
3636
```
3737

38-
## Endpoint 设置
39-
40-
SDK 支持多种方式配置 Endpoint,优先级从高到低:
41-
42-
1. **自定义 Endpoint**: 在客户端配置中指定 `host` (e.g. `open.volcengineapi.com`).
43-
2. **自动寻址**: 指定 `region`,SDK 会根据服务名和区域自动构造 Endpoint (e.g. `ecs.cn-beijing.volcengineapi.com`).
44-
3. **默认**: 如果未指定且无法推导,默认使用 `open.volcengineapi.com`.
45-
4638
## 快速开始
4739

4840
以下示例展示了如何初始化客户端并发送请求。
49-
安装对应的业务 SDK 包(如 `@volcengine/iam`)。
41+
安装对应的业务 SDK 包(如 `@volcengine/ecs`)。
5042

5143
```bash
5244
# pnpm
53-
pnpm add @volcengine/iam
45+
pnpm add @volcengine/ecs
5446

5547
```
5648

5749
```typescript
58-
import { IAMClient } from "@volcengine/iam"; // 需安装对应的业务包
50+
import { ECSClient, DescribeZonesCommand } from "@volcengine/ecs"; // 需安装对应的业务包
5951

6052
// 1. 使用环境变量中的 AK/SK,并指定 Region
61-
const client = new IAMClient({
53+
const client = new ECSClient({
6254
region: "cn-beijing",
6355
});
6456

6557
// 2. 或者在代码中显式传入 AK/SK
66-
// const client = new IAMClient({
58+
// const client = new ECSClient({
6759
// accessKeyId: "YOUR_AK",
6860
// secretAccessKey: "YOUR_SK",
6961
// region: "cn-beijing",
@@ -72,7 +64,7 @@ const client = new IAMClient({
7264
async function main() {
7365
try {
7466
// 发送请求 (具体 Command 需参考业务 SDK 文档)
75-
const command = new ListUsersCommand({});
67+
const command = new DescribeZonesCommand({});
7668
const response = await client.send(command);
7769
console.log(response);
7870
} catch (error) {

SDK_Integration.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,10 @@ The backoff strategy determines the wait time between each retry. You can choose
441441
- `ExponentialWithRandomJitterBackoffStrategy` (Default): Exponential backoff with jitter. Adds a random delay on top of exponential backoff to help avoid "thundering herd" effects.
442442

443443
```typescript
444+
import { StrategyName } from "@volcengine/sdk-core";
444445
const client = new EcsClient({
445446
// ... other configurations
446-
retryMode: "ExponentialBackoffStrategy",
447+
strategyName: StrategyName.ExponentialWithRandomJitterBackoffStrategy,
447448
});
448449
```
449450

@@ -502,7 +503,7 @@ try {
502503
if (error.status !== undefined) {
503504
// 1.1 SSL Error (status === 0)
504505
if (error.status === 0) {
505-
console.error(`❌ SSL Error: ${error.message}`);
506+
console.error(`❌ SSL Error`);
506507
}
507508
// 1.2 Server returned error (status > 0)
508509
else {
@@ -514,7 +515,6 @@ try {
514515
console.error(` RequestId: ${RequestId}`);
515516
} else {
516517
// Other HTTP errors (such as 404, 500, 502, etc.)
517-
console.error(`❌ HTTP Error ${error.status}: ${error.message}`);
518518
}
519519
}
520520
}
@@ -530,17 +530,12 @@ try {
530530
}
531531
// 3. Handle other SDK exceptions (Exception)
532532
else {
533-
console.error("❌ SDK Exception Occurred:");
534-
console.error(` Message: ${error.message}`);
535-
console.error(` Name: ${error.name}`);
536-
if (error.originalError) {
537-
console.error(" Cause:", error.originalError);
538-
}
533+
console.error("❌ SDK Exception Occurred");
539534
}
540535
}
541536
// 4. Unknown error (Error not thrown by SDK)
542537
else {
543-
console.error("❌ Unknown Error:", error);
538+
console.error("❌ Unknown Error");
544539
}
545540
}
546541
```

SDK_Integration_zh.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,11 @@ SDK 只会对特定的错误进行重试,包括:
441441
- `ExponentialWithRandomJitterBackoffStrategy` (默认): 带抖动的指数退避。在指数退避的基础上增加一个随机延迟,有助于避免“惊群效应”。
442442

443443
```typescript
444+
import { StrategyName } from "@volcengine/sdk-core";
445+
444446
const client = new EcsClient({
445447
// ... 其他配置
446-
retryMode: "ExponentialBackoffStrategy",
448+
strategyName: StrategyName.ExponentialWithRandomJitterBackoffStrategy,
447449
});
448450
```
449451

@@ -502,7 +504,7 @@ try {
502504
if (error.status !== undefined) {
503505
// 1.1 SSL 错误 (status === 0)
504506
if (error.status === 0) {
505-
console.error(`❌ SSL Error: ${error.message}`);
507+
console.error(`❌ SSL Error`);
506508
}
507509
// 1.2 服务端返回的错误 (status > 0)
508510
else {
@@ -514,7 +516,6 @@ try {
514516
console.error(` RequestId: ${RequestId}`);
515517
} else {
516518
// 其他 HTTP 错误 (如 404, 500, 502 等)
517-
console.error(`❌ HTTP Error ${error.status}: ${error.message}`);
518519
}
519520
}
520521
}
@@ -530,17 +531,12 @@ try {
530531
}
531532
// 3. 处理其他 SDK 异常 (Exception)
532533
else {
533-
console.error("❌ SDK Exception Occurred:");
534-
console.error(` Message: ${error.message}`);
535-
console.error(` Name: ${error.name}`);
536-
if (error.originalError) {
537-
console.error(" Cause:", error.originalError);
538-
}
534+
console.error("❌ SDK Exception Occurred");
539535
}
540536
}
541537
// 4. 未知错误 (非 SDK 抛出的错误)
542538
else {
543-
console.error("❌ Unknown Error:", error);
539+
console.error("❌ Unknown Error");
544540
}
545541
}
546542
```

packages/sdk-core/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
export { Client } from "./client/Client";
2-
export { ClientConfig, CommandOutput, HttpRequestError } from "./types/types";
2+
export {
3+
ClientConfig,
4+
CommandOutput,
5+
HttpRequestError,
6+
StrategyName,
7+
} from "./types/types";
38
export { Command } from "./command/Command";
49
export { buildRequestConfigFromMetaPath } from "./utils/meta";

packages/sdk-core/src/types/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export interface SendOptions {
128128
/**
129129
* AbortController 的 signal,用于取消请求
130130
*/
131-
abortSignal?: any;
131+
abortSignal?: AbortSignal;
132132
/**
133133
* Request-level timeout in milliseconds
134134
* Overrides client-level httpOptions.timeout

0 commit comments

Comments
 (0)