Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# copy to .dev.vars for `wrangler dev`; in production set it with `wrangler secret put ADMIN_TOKEN`
ADMIN_TOKEN=change-me
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: ci

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
persist-credentials: false
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v5
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm typecheck
- run: pnpm test
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ All requests carry `Authorization: Bearer <token>`.

## Self-hosting

Cloudflare Workers with KV and R2 (the paid plan's lowest tier is enough).
Cloudflare Workers with one R2 bucket (the paid plan's lowest tier is enough). R2 holds both the package content and the metadata: it is strongly consistent, so a revoked token stops working at once and a published pointer is served at once.

1. Fork or clone. Create a KV namespace and an R2 bucket, put their names into `wrangler.toml`.
1. Fork or clone. Create an R2 bucket and put its name into `wrangler.toml`.
2. `npx wrangler secret put ADMIN_TOKEN`
3. `pnpm install && pnpm deploy`; optionally connect the repo in the Cloudflare dashboard so a push deploys.
4. `tinyui apps create …`, `tinyui packages create …`, `tinyui tokens create …` against your host, then point each App's `fetch` base at `https://<host>/<app>/<channel>`.

Local run: `pnpm dev` (`.dev.vars` holds `ADMIN_TOKEN`, see `.dev.vars.example`). Tests: `pnpm test` (Workers runtime with KV and R2 emulated).
Local run: `pnpm dev` (`.dev.vars` holds `ADMIN_TOKEN`, see `.dev.vars.example`). Tests: `pnpm test` (Workers runtime with R2 emulated).

Storage sits behind `src/storage.ts`'s `Storage` interface: `KvR2Storage` for Cloudflare, `MemoryStorage` for tests and other runtimes.
Storage sits behind `src/storage.ts`'s `Storage` interface: `R2Storage` for Cloudflare, `MemoryStorage` for tests and other runtimes.

## License

Expand Down
8 changes: 4 additions & 4 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@

## 私有化部署

Cloudflare Workers + KV + R2(付费版最低档即可)。
Cloudflare Workers + 一个 R2 桶(付费版最低档即可)。包内容与元数据都放 R2:它是强一致的,token 吊销即时生效,指针发布即时可见。

1. fork 或 clone。建一个 KV namespace 与一个 R2 桶,名字填进 `wrangler.toml`。
1. fork 或 clone。建一个 R2 桶,名字填进 `wrangler.toml`。
2. `npx wrangler secret put ADMIN_TOKEN`
3. `pnpm install && pnpm deploy`;也可在 Cloudflare 后台连上仓库,push 即部署。
4. 对自己的实例跑 `tinyui apps create …`、`tinyui packages create …`、`tinyui tokens create …`,然后把各 App 的 `fetch` base 指向 `https://<host>/<app>/<channel>`。

本地运行:`pnpm dev`(`.dev.vars` 放 `ADMIN_TOKEN`,见 `.dev.vars.example`)。测试:`pnpm test`(Workers 运行时,KV 与 R2 由 miniflare 模拟)。
本地运行:`pnpm dev`(`.dev.vars` 放 `ADMIN_TOKEN`,见 `.dev.vars.example`)。测试:`pnpm test`(Workers 运行时,R2 由 miniflare 模拟)。

存储收在 `src/storage.ts` 的 `Storage` 接口后:Cloudflare 用 `KvR2Storage`,测试与其他运行时用 `MemoryStorage`。
存储收在 `src/storage.ts` 的 `Storage` 接口后:Cloudflare 用 `R2Storage`,测试与其他运行时用 `MemoryStorage`。

## License

Expand Down
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "tinyui-updates-server",
"version": "0.1.0",
"private": true,
"description": "Hot update delivery and publishing for TinyUI packages, on Cloudflare Workers",
"license": "MIT",
"type": "module",
"packageManager": "pnpm@10.20.0",
"engines": {
"node": ">=22"
},
"scripts": {
"dev": "wrangler dev",
"deploy": "wrangler deploy",
"typecheck": "tsc --noEmit",
"test": "vitest run"
},
"dependencies": {
"hono": "4.13.8"
},
"devDependencies": {
"@cloudflare/vitest-pool-workers": "0.22.0",
"@cloudflare/workers-types": "5.20260922.1",
"typescript": "7.0.2",
"vitest": "4.1.0",
"wrangler": "4.136.2"
}
}
Loading
Loading