Skip to content

Commit

Permalink
Merge branch 'main' of github.com:aircodelabs/aircode
Browse files Browse the repository at this point in the history
  • Loading branch information
adcentury committed Jun 27, 2023
2 parents 2cb7188 + 0084406 commit d980a52
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/en/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const sidebar: DefaultTheme.Sidebar = {
{ text: 'Send HTTP Request', link: '/guide/functions/http-request' },
{ text: 'POST Parameters', link: '/guide/functions/post-params' },
{ text: 'GET Parameters', link: '/guide/functions/get-params' },
{ text: 'ESM Support', link: '/guide/functions/esm' },
],
},
],
Expand Down
4 changes: 2 additions & 2 deletions docs/en/.vitepress/tutorial-list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default [
{ text: 'Connect Siri to ChatGPT', link: 'https://aircode.cool/hpwdi7n719' },
{ text: 'Build a Discord ChatGPT Bot', link: 'https://aircode.cool/zsgdima57c' },
{ text: 'Build a Slack ChatGPT Bot', link: 'https://aircode.cool/vkx3j8c9q5' },
{ text: 'Build Discord ChatGPT Bot', link: 'https://aircode.cool/zsgdima57c' },
{ text: 'Build Slack ChatGPT App', link: 'https://aircode.cool/vkx3j8c9q5' },
];
2 changes: 1 addition & 1 deletion docs/en/src/chatgpt/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ aside: false

# Build a ChatGPT Bot with JavaScript in Just 5 Minutes

Build a ChatGPT bot in just 5 minutes with this comprehensive tutorial. [简体中文版](https://docs-cn.aircode.io/chatgpt/)
Build a ChatGPT bot in just 5 minutes with this comprehensive tutorial.

## Choose a tutorial to enter, includes all source code, free hosting.

Expand Down
32 changes: 32 additions & 0 deletions docs/en/src/guide/functions/esm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ESM Support {#intro}

AirCode supports Node.js's ECMAScript Modules (ESM). You can directly use ESM syntax in files with the `.mjs` extension.

ESM syntax provides convenience in the following scenarios:
1. Using `import` / `export` statements for importing and exporting modules, providing clearer dependency relationships.
2. More compliant with the ECMAScript specification, consistent with front-end JavaScript modularization, facilitating code sharing between the server and the front end.
3. And more...

## Create .mjs Files {#create}

In your project, you can directly create a file with the `.mjs` extension, such as `main.mjs`. In `.mjs` files, you can normally use ESM syntax, and can debug and deploy like files with the `.js` extension.

For example, create a file named `main.mjs`, the default code is as follows:

```js
// @see https://docs.aircode.io/guide/functions/
import aircode from 'aircode';

export default async function (params, context) {
console.log('Received params:', params);
return {
message: 'Hi, AirCode.',
};
};
```

Click **Debug**, and you will see the output `Hi, AirCode` in the **Response** section.

## More Information {#more}

For more information about ECMAScript Modules (ESM) and `.mjs` files, please refer to [Node.js Documentation - ECMAScript Modules](https://nodejs.org/api/esm.html).
1 change: 1 addition & 0 deletions docs/zh-cn/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const sidebar: DefaultTheme.Sidebar = {
{ text: '发送 HTTP 请求', link: '/guide/functions/http-request' },
{ text: '获取 POST 参数', link: '/guide/functions/post-params' },
{ text: '获取 GET 参数', link: '/guide/functions/get-params' },
{ text: 'ESM 支持', link: '/guide/functions/esm'},
// { text: '获取请求头和方法', link: '/guide/functions/request-header-and-method' },
// { text: '设置返回头和状态码', link: '/guide/functions/response-header-and-code' },
// { text: '私有函数', link: '/guide/functions/private' },
Expand Down
4 changes: 2 additions & 2 deletions docs/zh-cn/.vitepress/tutorial-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export default [
{ text: '开发飞书 ChatGPT 机器人', link: 'https://aircode.cool/q4y1msdim4' },
{ text: '开发钉钉 ChatGPT 机器人', link: 'https://aircode.cool/xspb3by9fs' },
{ text: '开发企业微信 ChatGPT 应用', link: 'https://aircode.cool/54fhemjpk2' },
{ text: '开发 Slack ChatGPT 机器人', link: 'https://aircode.cool/zx85v6ac4s' },
{ text: '开发 Discord ChatGPT 机器人', link: 'https://aircode.cool/uumhsex1uc' },
{ text: '开发 Slack ChatGPT 应用', link: 'https://aircode.cool/zx85v6ac4s' },
{ text: '开发 Discord ChatGPT Bot', link: 'https://aircode.cool/uumhsex1uc' },
];
2 changes: 1 addition & 1 deletion docs/zh-cn/src/chatgpt/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ aside: false

# 5 分钟用 JavaScript 接入 ChatGPT 手把手教程

仅需 5 分钟,快速开发一个 ChatGPT 机器人,下面为全部教程。 [English Version](https://docs.aircode.io/chatgpt/)
仅需 5 分钟,快速开发一个 ChatGPT 机器人,下面为全部教程。

## 选择一个教程进入(含全部源码,免费托管)

Expand Down
32 changes: 32 additions & 0 deletions docs/zh-cn/src/guide/functions/esm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ESM 支持 {#intro}

AirCode 支持 Node.js 的 ECMAScript 模块 (ESM),你可以在 `.mjs` 后缀名的文件中直接使用 ESM 语法。

ESM 语法为你在以下场景提供便利:
1. 利用 `import` / `export` 语句对模块进行导入导出,提供更清晰的依赖关系。
3. 更加符合 ECMAScript 规范,与前端 JavaScript 模块化方式一致,方便进行服务器与前端的代码共享。
4. 更多……

## 创建 .mjs 文件 {#create}

在你的项目中,你可以直接创建一个 `.mjs` 后缀名的文件,例如 `main.mjs`。在 `.mjs` 文件中,你可以正常使用 ESM 语法,且可像 `.js` 后缀名的文件一样进行调试和部署。

例如,创建一个名为 `main.mjs` 的文件,默认的代码如下:

```js
// @see https://docs.aircode.io/guide/functions/
import aircode from 'aircode';

export default async function (params, context) {
console.log('Received params:', params);
return {
message: 'Hi, AirCode.',
};
};
```

点击 **Debug**,你就会在 **Response** 栏看到 `Hi AirCode` 的输出。

## 更多信息 {#more}

关于 ECMAScript 模块 (ESM) 和 `.mjs` 文件的更多信息,请参考 [Node.js 文档 - ECMAScript Modules](https://nodejs.org/api/esm.html)
8 changes: 4 additions & 4 deletions docs/zh-cn/src/help/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
1. 我们的 [GitHub 仓库](https://github.com/aircodelabs/aircode),可以提 issue 或者直接贡献代码
2. 直接发邮件给我们 [email protected]
3. 我们的 [Discord 讨论区](https://discord.com/invite/XrMVdYdEuY)
4. 我们的[飞书用户群](https://applink.feishu.cn/client/chat/chatter/add_by_link?link_token=6dem4ab3-d523-4562-9c63-9fb46d565b10),点击链接或扫描下面的二维码加入
4. 我们的[飞书用户群](https://applink.feishu.cn/client/chat/chatter/add_by_link?link_token=988pd70a-e66a-49bd-9eac-09acba329491),点击链接或扫描下面的二维码加入

<img src="../public/_images/help/feishu.png" width="160px" style="margin-left:30px;"/>
<img src="/_images/help/feishu2.png" width="160px" style="margin-left:30px;"/>

5. 我们的微信群,微信扫描下面的二维码加入

<img src="../public/_images/help/weixin.png" width="160px" style="margin-left:30px;"/>
<img src="/_images/help/weixin.png" width="160px" style="margin-left:30px;"/>

6. 我们的钉钉群,钉钉扫描下面的二维码加入

<img src="../public/_images/help/dingding.png" width="160px" style="margin-left:30px;"/>
<img src="/_images/help/dingding.png" width="160px" style="margin-left:30px;"/>

Binary file added docs/zh-cn/src/public/_images/help/feishu2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d980a52

Please sign in to comment.