Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

refactor: move to typescript, optimize code structure #19

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
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
38 changes: 38 additions & 0 deletions .github/workflows/autofix-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: autofix.ci
on:
push:
branches:
- main

pull_request: {}

permissions:
contents: read

jobs:
autofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PNPM
run: corepack enable

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: pnpm

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: ni --no-frozen-lockfile

- name: Lint and fix
run: nr lint:fix

- uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84
with:
commit-message: "chore: apply automatic fixes"
52 changes: 0 additions & 52 deletions .github/workflows/build.yml

This file was deleted.

87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PNPM
run: corepack enable

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: pnpm

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: nci

- name: Lint
run: nr lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PNPM
run: corepack enable

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: pnpm

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: nci

- name: Typecheck
run: nr typecheck

test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node: [16.x, 18.x, 20.x]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false

steps:
- uses: actions/checkout@v4

- name: Setup PNPM
run: corepack enable

- name: Set node version to ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: pnpm

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: nci

- name: Test
run: nr test
27 changes: 27 additions & 0 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lock Threads

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch: {}

permissions:
issues: write
pull-requests: write

concurrency:
group: lock

jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
issue-inactive-days: "14"
issue-comment: |
This issue has been locked since it has been closed for more than 14 days.

If you have found a concrete bug or regression related to it, please open a new [issue](./new/choose). If you have any other comments you should create a new [discussion](../discussions/new/choose).
process-only: issues
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release

on:
push:
tags:
- "v*"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 20.x

- run: npx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
.cache
.DS_Store
.idea
*.log
*.tgz
coverage
dist
lib-cov
logs
node_modules
package-lock.json
doc/node_modules
dist/
temp
docs/.vitepress/cache
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore-workspace-root-check=true
git-checks=false
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/public/cw.js
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.experimental.useFlatConfig": true,
"yaml.schemas": {
"./schema/config.schema.json": "/config.yaml"
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ General Public License ever published by the Free Software Foundation.
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Library.
52 changes: 23 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
# ClientWorker

文档地址:[ClientWorker](https://clientworker.js.org)

↑这也是用ClientWorker搭建的!

## 它能干什么

- 绕备,在域名不变动的情况下,其余用户所有请求均可以定向到你的其他服务器或者cdn,而首屏域名无需ICP备案。
- 降本,你可以用廉价的家宽+公网ipv4/ipv6,即使是80/443被封锁,你也可以在不变动端口的情况下将用户流量引向家宽。
- 白嫖,可以用免费的公网穿透服务,接近零成本托管你的服务。
- 加速,将静态资源流量(乃至动态资源)**并发**到全球cdn,实现前端级负载均衡。
- 绕禁,通过在前端修改标头的方式,修复被故意篡改的`MIME`,正常托管网站,绕过各大托管商对于网站部署的限制,可以毫无负担的使用阿里云、腾讯云等对象存储而不用开启网站模式,乃至GithubRaw无限流量(绕过GithubPage 100GB限制)。
- 愈合:通过并发方式,辅助JSDelivr、Unpkg、cdnjs等大陆几乎不可达请求重定向至其他cdn,从而实现无修改、全球加速。
- 不宕,即使首屏服务器离线或不可达,已访问过的用户依旧可以正常命中备用服务器。
- 缓存,颗粒化控制缓存,多种情况不同选择,智能调度缓存和请求,避免有缓存时无返回、缓存无法及时更新问题,确保缓存在客户端工作的更顺畅。
- 离线,可以迅速支撑普通离线应用,助力快速构建PWA。
- 兼容,Webp无缝,可以通过判断标头来判断是否支持Webp,并且自动替换图片请求,为网站加速助力。
- 审核,通过内置的规则可以屏蔽并替换、拦截敏感词汇,实现网站内容安全。
- 无刷,你不需要刷新就可以激活ClientWorker
- 热更,即使源站完全宕机,你也可以更新用户手中的ClientWorker与配置,确保网站正常运行。
- 切片,对于一个请求发起多个切片以提高单文件下载速度
- 叠速,专门为ClientWorker开发的`KFCThursdayVW50`引擎能在浏览器端切片并同时并发不同的镜像服务器,对于下载大文件可以带宽叠加的效果。
- 均衡,对多个镜像并发,选择最优的镜像服务器,保证网站的响应速度,同时达到负载均衡的目的。
- 高度自定义...更多玩法等你挖掘

## License

GPL-3.0-or-later
# pkg-name

[![NPM version](https://img.shields.io/npm/v/pkg-name?color=a1b858&label=)](https://www.npmjs.com/package/pkg-name)

## 💎 Features

## 📦 Installation

```bash
$ npm install pkg-name
$ yarn add pkg-name
$ pnpm add pkg-name
```

## 🚀 Usage

```ts

```

## 📝 License

[MIT](./LICENSE). Made with ❤️ by [Ray](https://github.com/so1ve)
22 changes: 0 additions & 22 deletions cw.config.js

This file was deleted.

1 change: 0 additions & 1 deletion doc/.gitignore

This file was deleted.

Loading
Loading