chore: update readme

This commit is contained in:
Ou 2024-10-28 21:40:38 +08:00
parent 3cea7314c5
commit 1d32e96198
3 changed files with 30 additions and 6 deletions

3
.gitignore vendored
View File

@ -9,4 +9,5 @@ dist/
.env
.env.*
dev-dist
*.tsbuildinfo
*.tsbuildinfo
wrangler.toml

View File

@ -8,7 +8,9 @@ English | [简体中文](README.zh-CN.md)
## Deployment
If login and caching are not required, you can directly deploy to platforms like Cloudflare Pages or Vercel. Just fork the repository and import it into the respective platform. The build output directory for Cloudflare Pages is `dist/output/public`.
If login and caching are not required, you can directly deploy to platforms like Cloudflare Pages or Vercel. Just fork the repository and import it into the respective platform.
For Cloudflare Pages, you need to set the build command to `pnpm run build` and the build output directory to `dist/output/public`.
For login, which involves GitHub OAuth, you only need to [create a GitHub App](https://github.com/settings/applications/new). No special permissions are required. After creating the app, you will get a Client ID and Client Secret. Different platforms have different places to set environment variables; refer to the `example.env.server` file. If running locally, rename it to `.env.server` and add the necessary values.
@ -25,7 +27,19 @@ INIT_TABLE=true
This project primarily supports deployment on Cloudflare Pages and Docker. For Vercel, you need to set up your own database. Supported databases can be found at https://db0.unjs.io/connectors .
Cloudflare D1 database is free to use. You can manually create a database in the Cloudflare Worker control panel and add the `database_id` and `database_name` to the corresponding positions in `wrangler.toml`. The changes will take effect on the next deployment.
The Cloudflare D1 database can be used for free. To set it up, go to the Cloudflare Worker control panel and manually create a D1 database. Then, add the `database_id` and `database_name` to the corresponding fields in your `wrangler.toml` file.
If you don't have a `wrangler.toml` file, you can rename `example.wrangler.toml` to `wrangler.toml` and modify it with your configuration. The changes will take effect on your next deployment.
If you receive an error indicating that the database is empty during deployment, you can create a table arbitrarily. The first execution will automatically initialize the required tables. Alternatively, you can use the following SQL statement to create a Cache Table:
```sql
CREATE TABLE IF NOT EXISTS cache (
id TEXT PRIMARY KEY,
updated INTEGER,
data TEXT
);
```
For Docker deployment. In the project root directory with `docker-compose.yml`, run

View File

@ -9,7 +9,9 @@
## 部署
如果不需要登录,缓存,可以直接部署到 Cloudflare PagesVercel 等。Fork 之后在对应平台上导入即可。Cloudflare Pages 的构建输出文件夹是 `dist/output/public`
如果不需要登录,缓存,可以直接部署到 Cloudflare PagesVercel 等。Fork 之后在对应平台上导入即可。
Cloudflare Pages 需要填入构建命令 `pnpm run build`, 构建输出文件夹 `dist/output/public`
登录涉及到 Github Oauth只需要 [创建一个 Github App](https://github.com/settings/applications/new) 即可,不需要申请任何权限。然后就会得到 Client ID 和 Client Secret。关于环境变量不同平台有不同的填写位置请关注 `example.env.server` 文件。如果本地运行,需要将其重命名为 `.env.server`,然后按照要求添加。
@ -26,9 +28,16 @@ INIT_TABLE=true
本项目主推 Cloudflare Pages 以及 Docker 部署, Vercel 需要你自行搞定数据库,其他支持的数据库可以查看 https://db0.unjs.io/connectors 。
Cloudflare D1 数据库可以免费使用,在 Cloudflare Worker 控制面板里找到 D1 手动创建数据库,将 `database_id` 以及 `database_name` 填入 `wrangler.toml` 对应位置即可。下次部署时就可以生效了。
Cloudflare D1 数据库可以免费使用,在 Cloudflare Worker 控制面板里找到 D1 手动创建数据库,将 `database_id` 以及 `database_name` 填入 `wrangler.toml` 对应位置即可。没有 `wrangler.toml` 文件,可以把 `example.wrangler.toml` 重命名为 `wrangler.toml`, 将其修改为自己的配置,下次部署时就可以生效了。如果部署时,提示数据库里为空,可以随意创建一个表,第一次执行会自动初始化所需的表,也可以用下列语句创建 Cache Table
```sql
CREATE TABLE IF NOT EXISTS cache (
id TEXT PRIMARY KEY,
updated INTEGER,
data TEXT
);
```
Docker 部署,只需要项目根目录 `docker-compose.yaml` 文件,同一目录下执行
对于 Docker 部署,只需要项目根目录 `docker-compose.yaml` 文件,同一目录下执行
```
docker compose up
```