Skip to content

Commit d58b69a

Browse files
committed
[fix] doc变更
1 parent 301d0d3 commit d58b69a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+11364
-1580
lines changed

README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Tencent Cloud Base(TCB) Server Node.js SDK
22

3-
[![NPM Version](https://img.shields.io/npm/v/@cloudbase/node-sdk/beta)](https://www.npmjs.com/package/@cloudbase/node-sdk)
4-
![node (scoped)](https://img.shields.io/node/v/@cloudbase/node-sdk)
5-
[![Coverage Status](https://coveralls.io/repos/github/TencentCloudBase/node-sdk/badge.svg?branch=master)](https://coveralls.io/github/TencentCloudBase/node-sdk?branch=master)
6-
7-
> ⚠️ 当你计划在项目中使用 @cloudbase/node-sdk 替代 tcb-admin-node 时,请务必阅读[迁移文档](./docs/packageChange.md)
3+
> ⚠️ 当你计划在项目中使用 @cloudbase/node-sdk 替代 tcb-admin-node 时,请务必阅读[迁移文档](./docs/packageUpgrade.md)
84
95
## 目录
106

@@ -44,7 +40,7 @@ import tcb from '@cloudbase/node-sdk'
4440

4541
- [初始化](docs/initialization.md)
4642
- [存储](docs/storage.md)
47-
- [数据库](docs/database.md)
43+
- [数据库](docs/database/database.md)
4844
- [云函数](docs/functions.md)
4945
- [鉴权](./docs/auth.md)
5046
- [环境](./docs/env.md)

docs/auth.md

+100-17
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,116 @@
1-
### 获取auth的引用
1+
# 登录鉴权
22

3-
```js
4-
const tcb = require('@cloudbase/node-sdk');
5-
const app = tcb.init({env:'xxx', credentials:'xxx'})
6-
const auth = app.auth();
7-
```
3+
## getUserInfo
4+
5+
#### 1. 接口描述
6+
7+
接口功能:获取用户信息
8+
9+
接口声明:`getUserInfo(): Object`
10+
11+
#### 2. 输入参数
12+
13+
14+
15+
#### 3. 返回结果
16+
17+
| 字段 | 类型 | 必填 | 说明 |
18+
| ------------ | ------ | ---- | ------------------------------------------- |
19+
| openId | string || 微信 openId,非微信授权登录则空 |
20+
| appId | string || 微信 appId,非微信授权登录则空 |
21+
| uid | string || 用户唯一 ID |
22+
| customUserId | string || 开发者自定义的用户唯一 id,非自定义登录则空 |
823

9-
#### 获取用户信息
24+
#### 4. 示例代码
1025

1126
```js
12-
const {
13-
openId, //微信openId,非微信授权登录则空
14-
appId, //微信appId,非微信授权登录则空
15-
uid, //用户唯一ID
16-
customUserId //开发者自定义的用户唯一id,非自定义登录则空
17-
} = auth.getUserInfo()
27+
const tcb = require('@cloudbase/node-sdk')
28+
const app = tcb.init({ env: 'xxx' })
29+
const auth = app.auth()
30+
31+
exports.main = async (event, context) => {
32+
const {
33+
openId, //微信openId,非微信授权登录则空
34+
appId, //微信appId,非微信授权登录则空
35+
uid, //用户唯一ID
36+
customUserId //开发者自定义的用户唯一id,非自定义登录则空
37+
} = auth.getUserInfo()
38+
console.log(openId, appId, uid, customUserId)
39+
}
1840
```
1941

20-
#### 获取客户端IP
42+
## getClientIP
43+
44+
#### 1. 接口描述
45+
46+
接口功能:获取客户端 IP
47+
48+
接口声明:`getClientIP(): string`
49+
50+
#### 2. 输入参数
51+
52+
53+
54+
#### 3. 返回结果
55+
56+
| 字段 | 类型 | 必填 | 说明 |
57+
| ---- | ------ | ---- | --------- |
58+
| - | string || 客户端 IP |
59+
60+
#### 4. 示例代码
61+
2162
```js
22-
const ip = auth.getClientIP()
63+
const tcb = require('@cloudbase/node-sdk')
64+
const app = tcb.init({ env: 'xxx' })
65+
const auth = app.auth()
66+
67+
exports.main = async (event, context) => {
68+
const ip = auth.getClientIP() // string
69+
console.log(ip)
70+
}
2371
```
2472

25-
#### 获取自定义登录的登录凭据ticket
73+
## createTicket
74+
75+
#### 1. 接口描述
76+
77+
接口功能:获取自定义登录的登录凭据 ticket
78+
79+
接口声明:`createTicket(): string`
80+
81+
#### 2. 输入参数
82+
83+
| 字段 | 类型 | 必填 | 说明 |
84+
| ------------ | ------ | ---- | ------------------------------ |
85+
| customUserId | string || 开发者自定义的用户唯一 id |
86+
| option | string || 微信 appId,非微信授权登录则空 |
87+
88+
#### option
89+
90+
| 字段 | 类型 | 必填 | 说明 |
91+
| ------- | ------ | ---- | ----------------------- |
92+
| refresh | number || access_token 的刷新时间 |
93+
| expire | number || access_token 的过期时间 |
94+
95+
#### 3. 返回结果
96+
97+
| 字段 | 类型 | 必填 | 说明 |
98+
| ---- | ------ | ---- | --------------------- |
99+
| - | string || 自定义登录凭据 ticket |
100+
101+
#### 4. 示例代码
26102

27103
```js
104+
const tcb = require('@cloudbase/node-sdk')
105+
const app = tcb.init({ env: 'xxx' })
106+
107+
const auth = app.auth()
108+
28109
const customUserId = '123456' // 开发者自定义的用户唯一id
29110

30111
const ticket = auth.createTicket(customUserId, {
31-
refresh: 3600 * 1000, // access_token的刷新时间
112+
refresh: 3600 * 1000 // access_token的刷新时间
32113
})
114+
115+
console.log(ticket)
33116
```

0 commit comments

Comments
 (0)