Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add cloud sdk attribute introduction #1572

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/guide/function/function-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ title: 云函数 SDK
import cloud from "@lafjs/cloud";
```

## SDK 属性

`cloud` 具有下面的一些参数:

| 属性 | 介绍 |
| --------------- | ----------------------------------------------------------------------------------- |
| `cloud.appid` | 当前 Laf 应用的 appid |
| `cloud.database()` | 当前应用的数据库对象 |
| `cloud.env` | 当前应用的环境变量,也可用 `process.env` |
| `cloud.fetch` | 可在云函数中发起 HTTP 请求,基于`axios`封装 |
| `cloud.getToken` | 生成 JWT Token |
| `cloud.parseToken` | 解密 JWT Token |
| `cloud.invoke` | 请求其他云函数 |
| `cloud.shared` | 当前应用的全局缓存 |
| `cloud.mongo` | 当前应用的原生 MongoDB 实例 |
| `cloud.sockets` | 当前应用的socket实例|

## 发送网络请求

使用 `cloud.fetch()` 可发起 HTTP 请求,调用三方接口,可完成如支付接口、短信验证码等等三方接口操作。
Expand Down
Loading