mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat: migrate to Nuxt 4 (Nitro) and Tailwind CSS v3
This commit is contained in:
parent
f4959eebf8
commit
b139712a91
166 changed files with 19790 additions and 5539 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# API Overview
|
||||
|
||||
WebHooker exposes an HTTP API via Hono on Cloudflare Workers.
|
||||
WebHooker exposes an HTTP API via Nitro on Cloudflare Workers.
|
||||
|
||||
## Base URL
|
||||
|
||||
|
|
|
|||
|
|
@ -13,61 +13,75 @@ npm run dev # Start local dev server
|
|||
## Project Structure
|
||||
|
||||
```text
|
||||
src/
|
||||
├── index.ts # CF Workers entry (fetch + scheduled), scheduled = Discord command sync + Telegram webhook sync
|
||||
├── types.ts # Env, Config, Route, Filter, Group, WebhookEvent, NeutralMessage
|
||||
├── config.ts # Loads routes from KV (returns [] if unset), builds Config from env
|
||||
├── server.ts # Hono app: /health, /webhook, /discord/interactions, /telegram/webhook, mounts /auth, /admin + /
|
||||
├── core/
|
||||
│ └── dispatch.ts # Platform-neutral dispatch: match routes → formatEvent → getDriver().send/edit
|
||||
├── events/ # Provider-agnostic route matching
|
||||
│ └── match.ts # matchRoute, eventOwners, extractBranch, keyword filtering
|
||||
├── providers/ # Forge webhook providers (verify + parse/normalize)
|
||||
│ ├── types.ts # Provider interface (matches/verify/parse)
|
||||
│ ├── index.ts # detectProvider() registry (github, gitea)
|
||||
│ ├── github/ # X-GitHub-Event + X-Hub-Signature-256
|
||||
│ └── gitea/ # X-Gitea-Event + X-Gitea-Signature (normalized payloads)
|
||||
├── formatters/ # Platform-neutral formatters (produce NeutralMessage)
|
||||
│ ├── index.ts # formatEvent: 28-event switch → NeutralMessage + re-exports
|
||||
│ ├── colors.ts # GITHUB_COLORS + WORKFLOW_CONCLUSION_EMOJI
|
||||
│ ├── helpers.ts # emojiPrefix, T, buildMessage
|
||||
│ └── *.ts # push, pull-request, issues, comments, workflow, release, create, repo,
|
||||
│ # check, review, commit-comment, deployment, member, label, milestone,
|
||||
│ # discussion, repository, security, generic, ping
|
||||
├── drivers/ # Platform drivers (pluggable push targets)
|
||||
│ ├── types.ts # PlatformDriver interface + SendResult (send + edit)
|
||||
│ ├── index.ts # getDriver() registry (discord + telegram)
|
||||
│ ├── discord/ # index.ts (driver), render.ts (NeutralMessage → embed),
|
||||
│ │ # rest.ts, interactions.ts, commands.ts
|
||||
│ └── telegram/ # index.ts (driver), render.ts (NeutralMessage → Telegram HTML),
|
||||
│ # rest.ts (chat_id + message_thread_id), updates.ts (webhook verify),
|
||||
│ # commands.ts (/gh login|logout|comment|merge|close + reply parsing)
|
||||
├── github/ # GitHub OAuth + as-user actions
|
||||
│ ├── oauth.ts # OAuth URL, callback token exchange, getUserOctokit, comment/merge/close actions
|
||||
│ └── store.ts # KV token CRUD + D1 discord-link/telegram-link mapping
|
||||
├── web/ # HTTP UI/API routes
|
||||
│ ├── oauth-routes.ts # GET /auth/github, callback (admin session / discord-link / telegram-link), DELETE /token/:userId
|
||||
│ ├── action-routes.ts # POST /api/comment|merge|close|react (Bearer token auth via KV lookup)
|
||||
│ ├── admin-routes.ts # /admin API: routes, groups, me, logs (session + scope auth)
|
||||
│ ├── session.ts # Admin session CRUD (KV session:{id}), cookie helpers
|
||||
│ ├── groups.ts # Group loading, group-admin access scoping
|
||||
│ ├── home-routes.ts # Landing page routes
|
||||
│ ├── legal-routes.ts # Legal page routes
|
||||
│ └── richheader-routes.ts # GET /api/richheader (Telegram avatar card)
|
||||
└── lib/ # Shared infrastructure
|
||||
├── i18n.ts # Message language overrides (en/zh)
|
||||
├── send-log.ts # Send logging (D1 send_logs)
|
||||
├── log.ts # JSON console logger (info/warn/error/fatal)
|
||||
└── locales/ # en.ts, zh.ts translation dictionaries
|
||||
app/ # Vue 3 UI (Nuxt app dir)
|
||||
├── app.vue # Root component (NuxtPage)
|
||||
├── assets/css/main.css # Tailwind CSS entry: theme tokens (RGB-triplet CSS variables) + @layer components (@apply)
|
||||
├── pages/ # index (landing), terms, privacy, admin/[...slug] (console SPA)
|
||||
├── components/ # ConsolePage, RouteCard/Editor, GroupEditor, MembersPanel, WebhookPanel,
|
||||
│ # SendLogs, AuditLog, AppToasts, LegalLayout
|
||||
├── composables/ # useI18n, useToasts, useGroups, useGroupRoutes, useLogs, useAudit, useInvites, useWebhook
|
||||
├── types.ts # Shared client types (Route, Group, Filter, ...)
|
||||
└── utils/legal.ts # Terms/privacy HTML bodies (zh/en)
|
||||
server/ # Nitro server (H3 handlers in server/routes/)
|
||||
├── routes/ # /health, /webhook[/:groupId], /discord/interactions, /telegram/webhook,
|
||||
│ # /auth/github*, /admin/{login,logout,invite,api/**}, /api/{comment,merge,close,react,richheader}
|
||||
├── tasks/ # Scheduled (cron */5): discord-sync, telegram-sync, audit-prune
|
||||
├── error-handler.ts # JSON error handler
|
||||
└── lib/
|
||||
├── types.ts # Env, Config, Route, Filter, Group, WebhookEvent, NeutralMessage
|
||||
├── config.ts # Loads routes from KV (returns [] if unset), builds Config from env
|
||||
├── core/
|
||||
│ └── dispatch.ts # Platform-neutral dispatch: match routes → formatEvent → getDriver().send/edit
|
||||
├── events/ # Provider-agnostic route matching
|
||||
│ └── match.ts # matchRoute, eventOwners, extractBranch, keyword filtering
|
||||
├── providers/ # Forge webhook providers (verify + parse/normalize)
|
||||
│ ├── types.ts # Provider interface (matches/verify/parse)
|
||||
│ ├── index.ts # detectProvider() registry (github, gitea, custom)
|
||||
│ ├── github/ # X-GitHub-Event + X-Hub-Signature-256
|
||||
│ └── gitea/ # X-Gitea-Event + X-Gitea-Signature (normalized payloads)
|
||||
├── formatters/ # Platform-neutral formatters (produce NeutralMessage)
|
||||
│ ├── index.ts # formatEvent: 29-event switch → NeutralMessage + re-exports
|
||||
│ ├── colors.ts # GITHUB_COLORS + WORKFLOW_CONCLUSION_EMOJI
|
||||
│ ├── helpers.ts # emojiPrefix, T, buildMessage, commitLink/branchLink/tagLink
|
||||
│ └── *.ts # push, pull-request, issues, comments, workflow, release, create, repo,
|
||||
│ # check, review, commit-comment, deployment, member, label, milestone,
|
||||
│ # discussion, repository, security, generic, ping, custom
|
||||
├── drivers/ # Platform drivers (pluggable push targets)
|
||||
│ ├── types.ts # PlatformDriver interface + SendResult (send + edit)
|
||||
│ ├── index.ts # getDriver() registry (discord + telegram)
|
||||
│ ├── discord/ # index.ts (driver), render.ts (NeutralMessage → embed),
|
||||
│ │ # rest.ts, interactions.ts, commands.ts
|
||||
│ └── telegram/ # index.ts (driver), render.ts (NeutralMessage → Telegram HTML),
|
||||
│ # rest.ts (chat_id + message_thread_id), updates.ts (webhook verify),
|
||||
│ # commands.ts (/gh login|logout|comment|merge|close + reply parsing)
|
||||
├── github/ # GitHub OAuth + as-user actions
|
||||
│ ├── oauth.ts # OAuth URL, callback token exchange, getUserOctokit, comment/merge/close actions
|
||||
│ └── store.ts # KV token CRUD + D1 discord-link/telegram-link mapping
|
||||
├── web/ # HTTP UI/API logic (called from server/routes)
|
||||
│ ├── oauth.ts # GET /auth/github, callback (admin session / discord-link / telegram-link / install bind)
|
||||
│ ├── actions.ts # POST /api/comment|merge|close|react (Bearer token auth via KV lookup)
|
||||
│ ├── admin.ts # /admin API: routes, groups, me, logs, invites, audit (session + scope auth)
|
||||
│ ├── auth.ts # Shared auth middleware + guards
|
||||
│ ├── invites.ts # Invite CRUD + acceptInvite
|
||||
│ ├── session.ts # Admin session CRUD (KV session:{id}), cookie helpers
|
||||
│ ├── groups.ts # Group loading, group-admin access scoping
|
||||
│ ├── tenants.ts # Per-group webhook secret CRUD
|
||||
│ └── richheader.ts # GET /api/richheader (Telegram avatar card)
|
||||
└── lib/ # Shared infrastructure
|
||||
├── i18n.ts # Message language overrides (en/zh)
|
||||
├── send-log.ts # Send logging (D1 send_logs)
|
||||
├── audit.ts # Audit logging (D1 audit_logs)
|
||||
├── log.ts # JSON console logger (info/warn/error/fatal)
|
||||
└── locales/ # en.ts, zh.ts translation dictionaries
|
||||
|
||||
src/__tests__/ # Unit tests (bun test)
|
||||
tests/ # Unit tests (bun test)
|
||||
```
|
||||
|
||||
## Scripts
|
||||
|
||||
| Command | Description |
|
||||
| ---------------------- | ------------------------------- |
|
||||
| `npm run dev` | Start wrangler dev server |
|
||||
| `npm run dev` | Start Nuxt dev server (HMR) |
|
||||
| `npm run typecheck` | TypeScript type checking |
|
||||
| `npm run lint` | ESLint (TypeScript) |
|
||||
| `npm run lint:md` | Markdownlint (Markdown) |
|
||||
|
|
@ -100,11 +114,11 @@ curl http://localhost:8787/health
|
|||
|
||||
## Adding a New Event Formatter
|
||||
|
||||
1. Add the event type to `GITHUB_COLORS` in `src/formatters/colors.ts` (if new color needed)
|
||||
2. Add action labels to the locale dictionaries in `src/lib/locales/en.ts` and `src/lib/locales/zh.ts` (if new actions)
|
||||
3. Create a `formatEventType` function in `src/formatters/`
|
||||
4. Add the case to the `formatEvent` switch statement in `src/formatters/index.ts`
|
||||
5. Update `extractBranch` in `src/events/match.ts` if the event has branch info
|
||||
1. Add the event type to `GITHUB_COLORS` in `server/lib/formatters/colors.ts` (if new color needed)
|
||||
2. Add action labels to the locale dictionaries in `server/lib/lib/locales/en.ts` and `server/lib/lib/locales/zh.ts` (if new actions)
|
||||
3. Create a `formatEventType` function in `server/lib/formatters/`
|
||||
4. Add the case to the `formatEvent` switch statement in `server/lib/formatters/index.ts`
|
||||
5. Update `extractBranch` in `server/lib/events/match.ts` if the event has branch info
|
||||
6. Add the event to the documentation in `docs/events/supported.md` and `docs/zh/events/supported.md`
|
||||
7. Add the event to the README (`README.md` and `README.zh.md`) event tables and the GitHub App event subscription list
|
||||
8. Subscribe to the event in your GitHub App settings
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# Introduction
|
||||
|
||||
WebHooker is a GitHub/Gitea webhook dispatcher built on Cloudflare Workers. It receives webhook events from supported forges (GitHub, Gitea — more can be added via `src/providers/`), applies configurable filters, formats them into rich messages, and delivers them to Discord channels/threads (embeds) and Telegram chats/topics (HTML) via their REST APIs. In-Discord `/gh` interactions arrive via an HTTPS Interactions Endpoint (Ed25519-verified); Telegram `/gh` commands arrive via the Telegram webhook. Routes and groups are managed through a built-in Web UI.
|
||||
WebHooker is a GitHub/Gitea webhook dispatcher built on Cloudflare Workers. It receives webhook events from supported forges (GitHub, Gitea — more can be added via `server/lib/providers/`), applies configurable filters, formats them into rich messages, and delivers them to Discord channels/threads (embeds) and Telegram chats/topics (HTML) via their REST APIs. In-Discord `/gh` interactions arrive via an HTTPS Interactions Endpoint (Ed25519-verified); Telegram `/gh` commands arrive via the Telegram webhook. Routes and groups are managed through a built-in Web UI.
|
||||
|
||||
## Architecture
|
||||
|
||||
```text
|
||||
GitHub / Gitea Webhook → Cloudflare Worker (Hono)
|
||||
GitHub / Gitea Webhook → Cloudflare Worker (Nuxt 4 / Nitro)
|
||||
├── POST /webhook → detect provider → verify → dedup → filter → format → Discord (REST) / Telegram (Bot API)
|
||||
├── POST /discord/interactions → verify (Ed25519) → handle /gh slash & context commands
|
||||
├── POST /telegram/webhook → verify (secret token) → handle /gh commands
|
||||
|
|
@ -38,10 +38,10 @@ GitHub / Gitea Webhook → Cloudflare Worker (Hono)
|
|||
## Tech Stack
|
||||
|
||||
- **Runtime**: Cloudflare Workers
|
||||
- **HTTP Framework**: Hono
|
||||
- **HTTP Framework**: Nuxt 4 / Nitro (H3)
|
||||
- **Discord delivery**: Discord REST API (interactions via an Ed25519-verified HTTPS Interactions Endpoint)
|
||||
- **Telegram delivery**: Telegram Bot API (webhook with optional secret-token verification)
|
||||
- **Web UI**: Nuxt 3 static SPA served from Worker assets
|
||||
- **Web UI**: Nuxt 4 (Vue 3 + Tailwind CSS v3) — server-rendered home/legal pages, client-side `/admin` console
|
||||
- **Storage**: Cloudflare KV + D1
|
||||
- **Auth**: Web Crypto API (HMAC-SHA256, Ed25519), octokit (GitHub API)
|
||||
- **Language**: TypeScript
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# API 概览
|
||||
|
||||
WebHooker 通过 Hono 在 Cloudflare Workers 上提供 HTTP API。
|
||||
WebHooker 通过 Nitro(Nuxt 4)在 Cloudflare Workers 上提供 HTTP API。
|
||||
|
||||
## 基础 URL
|
||||
|
||||
|
|
|
|||
|
|
@ -13,61 +13,75 @@ npm run dev # 启动本地开发服务器
|
|||
## 项目结构
|
||||
|
||||
```text
|
||||
src/
|
||||
├── index.ts # CF Workers 入口 (fetch + scheduled),scheduled = Discord 命令同步 + Telegram webhook 同步
|
||||
├── types.ts # Env、Config、Route、Filter、Group、WebhookEvent、NeutralMessage
|
||||
├── config.ts # 从 KV 加载路由(未设置时返回 []),从 env 构建 Config
|
||||
├── server.ts # Hono 应用: /health、/webhook、/discord/interactions、/telegram/webhook,挂载 /auth、/admin + /
|
||||
├── core/
|
||||
│ └── dispatch.ts # 平台中立分发:匹配路由 → formatEvent → getDriver().send/edit
|
||||
├── events/ # 与提供方无关的路由匹配
|
||||
│ └── match.ts # matchRoute、eventOwners、extractBranch、关键词过滤
|
||||
├── providers/ # Forge webhook 提供方(验证 + 解析/归一化)
|
||||
│ ├── types.ts # Provider 接口(matches/verify/parse)
|
||||
│ ├── index.ts # detectProvider() 注册表(github、gitea)
|
||||
│ ├── github/ # X-GitHub-Event + X-Hub-Signature-256
|
||||
│ └── gitea/ # X-Gitea-Event + X-Gitea-Signature(归一化载荷)
|
||||
├── formatters/ # 平台中立格式化器(产出 NeutralMessage)
|
||||
│ ├── index.ts # formatEvent:28 事件 switch → NeutralMessage + re-export
|
||||
│ ├── colors.ts # GITHUB_COLORS + WORKFLOW_CONCLUSION_EMOJI
|
||||
│ ├── helpers.ts # emojiPrefix、T、buildMessage
|
||||
│ └── *.ts # push、pull-request、issues、comments、workflow、release、create、repo、
|
||||
│ # check、review、commit-comment、deployment、member、label、milestone、
|
||||
│ # discussion、repository、security、generic、ping
|
||||
├── drivers/ # 平台驱动(可插拔推送目标)
|
||||
│ ├── types.ts # PlatformDriver 接口 + SendResult(send + edit)
|
||||
│ ├── index.ts # getDriver() 注册表(discord + telegram)
|
||||
│ ├── discord/ # index.ts (驱动)、render.ts (NeutralMessage → embed)、
|
||||
│ │ # rest.ts、interactions.ts、commands.ts
|
||||
│ └── telegram/ # index.ts (驱动)、render.ts (NeutralMessage → Telegram HTML)、
|
||||
│ # rest.ts (chat_id + message_thread_id)、updates.ts (webhook 验签)、
|
||||
│ # commands.ts (/gh login|logout|comment|merge|close + 引用消息解析)
|
||||
├── github/ # GitHub OAuth + 以用户身份操作
|
||||
│ ├── oauth.ts # OAuth URL、回调 Token 交换、getUserOctokit、评论/合并/关闭操作
|
||||
│ └── store.ts # KV Token CRUD + D1 discord-link/telegram-link 映射
|
||||
├── web/ # HTTP UI/API 路由
|
||||
│ ├── oauth-routes.ts # GET /auth/github、回调(管理员会话 / Discord 绑定 / Telegram 绑定)、DELETE /token/:userId
|
||||
│ ├── action-routes.ts # POST /api/comment|merge|close|react (通过 KV 查找进行 Bearer Token 鉴权)
|
||||
│ ├── admin-routes.ts # /admin API:路由、分组、me、日志(会话 + 权限范围鉴权)
|
||||
│ ├── session.ts # 管理员会话 CRUD (KV session:{id})、Cookie 辅助函数
|
||||
│ ├── groups.ts # 分组加载、分组管理员权限范围
|
||||
│ ├── home-routes.ts # 落地页路由
|
||||
│ ├── legal-routes.ts # 法律页面路由
|
||||
│ └── richheader-routes.ts # GET /api/richheader(Telegram 头像卡片)
|
||||
└── lib/ # 共享基础设施
|
||||
├── i18n.ts # 消息语言覆盖 (en/zh)
|
||||
├── send-log.ts # 发送日志 (D1 send_logs)
|
||||
├── log.ts # JSON 控制台日志 (info/warn/error/fatal)
|
||||
└── locales/ # en.ts、zh.ts 翻译字典
|
||||
app/ # Vue 3 UI(Nuxt app 目录)
|
||||
├── app.vue # 根组件 (NuxtPage)
|
||||
├── assets/css/main.css # Tailwind CSS 入口:主题令牌(RGB 三元组 CSS 变量)+ @layer components (@apply)
|
||||
├── pages/ # index(落地页)、terms、privacy、admin/[...slug](控制台 SPA)
|
||||
├── components/ # ConsolePage、RouteCard/Editor、GroupEditor、MembersPanel、WebhookPanel、
|
||||
│ # SendLogs、AuditLog、AppToasts、LegalLayout
|
||||
├── composables/ # useI18n、useToasts、useGroups、useGroupRoutes、useLogs、useAudit、useInvites、useWebhook
|
||||
├── types.ts # 共享客户端类型 (Route、Group、Filter、...)
|
||||
└── utils/legal.ts # 服务条款/隐私政策 HTML 正文 (zh/en)
|
||||
server/ # Nitro 服务器(H3 处理器位于 server/routes/)
|
||||
├── routes/ # /health、/webhook[/:groupId]、/discord/interactions、/telegram/webhook、
|
||||
│ # /auth/github*、/admin/{login,logout,invite,api/**}、/api/{comment,merge,close,react,richheader}
|
||||
├── tasks/ # 定时任务 (cron */5):discord-sync、telegram-sync、audit-prune
|
||||
├── error-handler.ts # JSON 错误处理器
|
||||
└── lib/
|
||||
├── types.ts # Env、Config、Route、Filter、Group、WebhookEvent、NeutralMessage
|
||||
├── config.ts # 从 KV 加载路由(未设置时返回 []),从 env 构建 Config
|
||||
├── core/
|
||||
│ └── dispatch.ts # 平台中立分发:匹配路由 → formatEvent → getDriver().send/edit
|
||||
├── events/ # 与提供方无关的路由匹配
|
||||
│ └── match.ts # matchRoute、eventOwners、extractBranch、关键词过滤
|
||||
├── providers/ # Forge webhook 提供方(验证 + 解析/归一化)
|
||||
│ ├── types.ts # Provider 接口(matches/verify/parse)
|
||||
│ ├── index.ts # detectProvider() 注册表(github、gitea、custom)
|
||||
│ ├── github/ # X-GitHub-Event + X-Hub-Signature-256
|
||||
│ └── gitea/ # X-Gitea-Event + X-Gitea-Signature(归一化载荷)
|
||||
├── formatters/ # 平台中立格式化器(产出 NeutralMessage)
|
||||
│ ├── index.ts # formatEvent:29 事件 switch → NeutralMessage + re-export
|
||||
│ ├── colors.ts # GITHUB_COLORS + WORKFLOW_CONCLUSION_EMOJI
|
||||
│ ├── helpers.ts # emojiPrefix、T、buildMessage、commitLink/branchLink/tagLink
|
||||
│ └── *.ts # push、pull-request、issues、comments、workflow、release、create、repo、
|
||||
│ # check、review、commit-comment、deployment、member、label、milestone、
|
||||
│ # discussion、repository、security、generic、ping、custom
|
||||
├── drivers/ # 平台驱动(可插拔推送目标)
|
||||
│ ├── types.ts # PlatformDriver 接口 + SendResult(send + edit)
|
||||
│ ├── index.ts # getDriver() 注册表(discord + telegram)
|
||||
│ ├── discord/ # index.ts (驱动)、render.ts (NeutralMessage → embed)、
|
||||
│ │ # rest.ts、interactions.ts、commands.ts
|
||||
│ └── telegram/ # index.ts (驱动)、render.ts (NeutralMessage → Telegram HTML)、
|
||||
│ # rest.ts (chat_id + message_thread_id)、updates.ts (webhook 验签)、
|
||||
│ # commands.ts (/gh login|logout|comment|merge|close + 引用消息解析)
|
||||
├── github/ # GitHub OAuth + 以用户身份操作
|
||||
│ ├── oauth.ts # OAuth URL、回调 Token 交换、getUserOctokit、评论/合并/关闭操作
|
||||
│ └── store.ts # KV Token CRUD + D1 discord-link/telegram-link 映射
|
||||
├── web/ # HTTP UI/API 逻辑(由 server/routes 调用)
|
||||
│ ├── oauth.ts # GET /auth/github、回调(管理员会话 / Discord 绑定 / Telegram 绑定 / install 绑定)
|
||||
│ ├── actions.ts # POST /api/comment|merge|close|react (通过 KV 查找进行 Bearer Token 鉴权)
|
||||
│ ├── admin.ts # /admin API:路由、分组、me、日志、邀请、审计(会话 + 权限范围鉴权)
|
||||
│ ├── auth.ts # 共享鉴权中间件 + 守卫
|
||||
│ ├── invites.ts # 邀请 CRUD + acceptInvite
|
||||
│ ├── session.ts # 管理员会话 CRUD (KV session:{id})、Cookie 辅助函数
|
||||
│ ├── groups.ts # 分组加载、分组管理员权限范围
|
||||
│ ├── tenants.ts # 每分组 webhook 密钥 CRUD
|
||||
│ └── richheader.ts # GET /api/richheader(Telegram 头像卡片)
|
||||
└── lib/ # 共享基础设施
|
||||
├── i18n.ts # 消息语言覆盖 (en/zh)
|
||||
├── send-log.ts # 发送日志 (D1 send_logs)
|
||||
├── audit.ts # 审计日志 (D1 audit_logs)
|
||||
├── log.ts # JSON 控制台日志 (info/warn/error/fatal)
|
||||
└── locales/ # en.ts、zh.ts 翻译字典
|
||||
|
||||
src/__tests__/ # 单元测试 (bun test)
|
||||
tests/ # 单元测试 (bun test)
|
||||
```
|
||||
|
||||
## 脚本
|
||||
|
||||
| 命令 | 说明 |
|
||||
| ---------------------- | ----------------------------- |
|
||||
| `npm run dev` | 启动 wrangler dev 服务器 |
|
||||
| `npm run dev` | 启动 Nuxt 开发服务器 (HMR) |
|
||||
| `npm run typecheck` | TypeScript 类型检查 |
|
||||
| `npm run lint` | ESLint (TypeScript) |
|
||||
| `npm run lint:md` | Markdownlint (Markdown) |
|
||||
|
|
@ -100,11 +114,11 @@ curl http://localhost:8787/health
|
|||
|
||||
## 添加新事件格式化器
|
||||
|
||||
1. 将事件类型添加到 `src/formatters/colors.ts` 中的 `GITHUB_COLORS`(如果需要新颜色)
|
||||
2. 将操作标签添加到 `src/lib/locales/en.ts` 与 `src/lib/locales/zh.ts` 的翻译字典(如果有新操作)
|
||||
3. 在 `src/formatters/` 中创建 `formatEventType` 函数
|
||||
4. 将 case 添加到 `src/formatters/index.ts` 中的 `formatEvent` switch 语句
|
||||
5. 如果事件包含分支信息,更新 `src/events/match.ts` 中的 `extractBranch`
|
||||
1. 将事件类型添加到 `server/lib/formatters/colors.ts` 中的 `GITHUB_COLORS`(如果需要新颜色)
|
||||
2. 将操作标签添加到 `server/lib/lib/locales/en.ts` 与 `server/lib/lib/locales/zh.ts` 的翻译字典(如果有新操作)
|
||||
3. 在 `server/lib/formatters/` 中创建 `formatEventType` 函数
|
||||
4. 将 case 添加到 `server/lib/formatters/index.ts` 中的 `formatEvent` switch 语句
|
||||
5. 如果事件包含分支信息,更新 `server/lib/events/match.ts` 中的 `extractBranch`
|
||||
6. 将事件添加到 `docs/events/supported.md` 与 `docs/zh/events/supported.md` 文档中
|
||||
7. 将事件添加到 README(`README.md` 与 `README.zh.md`)的事件表与 GitHub App 事件订阅列表中
|
||||
8. 在 GitHub App 设置中订阅该事件
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# 简介
|
||||
|
||||
WebHooker 是一个基于 Cloudflare Workers 构建的 GitHub/Gitea webhook 调度器。它接收来自受支持 forge(GitHub、Gitea——更多可通过 `src/providers/` 扩展)的 webhook 事件,应用可配置的过滤器,将事件格式化为富消息,并通过各自 REST API 投递到 Discord 频道/子区(embed)与 Telegram 群组/话题(HTML)。Discord 内的 `/gh` 交互通过 HTTPS Interactions Endpoint(Ed25519 验签)送达;Telegram 的 `/gh` 命令通过 Telegram webhook 送达。路由与分组通过内置的 Web UI 管理。
|
||||
WebHooker 是一个基于 Cloudflare Workers 构建的 GitHub/Gitea webhook 调度器。它接收来自受支持 forge(GitHub、Gitea——更多可通过 `server/lib/providers/` 扩展)的 webhook 事件,应用可配置的过滤器,将事件格式化为富消息,并通过各自 REST API 投递到 Discord 频道/子区(embed)与 Telegram 群组/话题(HTML)。Discord 内的 `/gh` 交互通过 HTTPS Interactions Endpoint(Ed25519 验签)送达;Telegram 的 `/gh` 命令通过 Telegram webhook 送达。路由与分组通过内置的 Web UI 管理。
|
||||
|
||||
## 架构
|
||||
|
||||
```text
|
||||
GitHub / Gitea Webhook → Cloudflare Worker (Hono)
|
||||
GitHub / Gitea Webhook → Cloudflare Worker (Nuxt 4 / Nitro)
|
||||
├── POST /webhook → 识别提供方 → 验证 → 去重 → 过滤 → 格式化 → Discord (REST) / Telegram (Bot API)
|
||||
├── POST /discord/interactions → 验证 (Ed25519) → 处理 /gh 斜杠与右键命令
|
||||
├── POST /telegram/webhook → 验证 (secret token) → 处理 /gh 命令
|
||||
|
|
@ -38,7 +38,7 @@ GitHub / Gitea Webhook → Cloudflare Worker (Hono)
|
|||
## 技术栈
|
||||
|
||||
- **运行时**: Cloudflare Workers
|
||||
- **HTTP 框架**: Hono
|
||||
- **HTTP 框架**: Nuxt 4 / Nitro (H3)
|
||||
- **Discord 投递**: Discord REST API(交互通过 Ed25519 验签的 HTTPS Interactions Endpoint)
|
||||
- **Telegram 投递**: Telegram Bot API(webhook 带可选 secret-token 校验)
|
||||
- **Web UI**: Nuxt 3 静态 SPA,由 Worker 资源托管
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue