Skip to content

Commit

Permalink
服务器部署支持模拟CloudflareR2存储
Browse files Browse the repository at this point in the history
  • Loading branch information
MarSeventh committed Nov 6, 2024
1 parent 2aa7094 commit c219dd1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@

2. 切换到项目根目录,运行`npm install`,安装所需依赖。

3. 在项目根目录下新建`wrangler.toml`配置文件,其内容为项目名称,环境变量(**包括`TG_BOT_TOKEN``TG_CHAT_ID`等必填参数**)等,可根据后文环境变量配置进行个性化修改。(详情参见官方文档[Configuration - Wrangler (cloudflare.com)](https://developers.cloudflare.com/workers/wrangler/configuration/)
3. 在项目根目录下新建`wrangler.toml`配置文件,其内容为项目名称,环境变量(**包括`TG_BOT_TOKEN``TG_CHAT_ID`等参数**)等,可根据后文环境变量配置进行个性化修改。(详情参见官方文档[Configuration - Wrangler (cloudflare.com)](https://developers.cloudflare.com/workers/wrangler/configuration/)

> 配置文件样例:
>
Expand All @@ -220,11 +220,17 @@
> TG_CHAT_ID = "your_bot_id"
> ```
4. 在项目根目录下运行`npm run start`,至此,正常情况下项目已经成功部署。
4. 在项目根目录下运行`npm run start`,至此,正常情况下项目已经成功部署。项目默认支持通过服务器**本地模拟的R2存储上传**。
程序默认运行在`8080`端口上,使用`nginx`等服务器反代`127.0.0.1:8080`即可外网访问服务。如需修改端口,可在`package.json`中修改`start`脚本的`port`参数(如下图)。
程序默认运行在`8080`端口上,使用`nginx`等服务器反代`127.0.0.1:8080`即可外网访问服务。如需修改端口,可在`package.json`中修改`start`脚本的`port`参数(如下)。
![](https://alist.sanyue.site/d/imgbed/202408191832173.png)
```toml
"scripts": {
"ci-test": "concurrently --kill-others \"npm start\" \"wait-on http://localhost:8080 && mocha\"",
"test": "mocha",
"start": "npx wrangler pages dev ./ --kv \"img_url\" --r2 \"img_r2\" --port 8080 --persist-to ./data"
}
```
正常启动,控制台输出如下:

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
"scripts": {
"ci-test": "concurrently --kill-others \"npm start\" \"wait-on http://localhost:8080 && mocha\"",
"test": "mocha",
"start": "npx wrangler pages dev ./ --kv \"img_url\" --port 8080 --persist-to ./data"
"start": "npx wrangler pages dev ./ --kv \"img_url\" --r2 \"img_r2\" --port 8080 --persist-to ./data"
},
"dependencies": {
"@cloudflare/pages-plugin-sentry": "^1.1.3",
"@sentry/tracing": "^7.114.0"
"@sentry/tracing": "^7.114.0",
"miniflare": "^3.20240718.0"
},
"devDependencies": {
"concurrently": "^8.2.2",
"mocha": "^10.6.0",
"wait-on": "^7.2.0",
"wrangler": "^3.63.0"
"wrangler": "^3.66.0"
}
}

0 comments on commit c219dd1

Please sign in to comment.