mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat: migrate send logs and discord links to D1
This commit is contained in:
parent
5a98e45544
commit
3a6a2cbbc5
16 changed files with 139 additions and 79 deletions
|
|
@ -77,7 +77,7 @@ Tokens are stored in KV with key pattern `token:{userId}`:
|
|||
}
|
||||
```
|
||||
|
||||
`expiresAt` is a Unix timestamp in milliseconds. KV entries expire at 90% of the token's lifetime (minimum 60 seconds). A reverse index `token-reverse:{sha256 of token}` maps the access token back to its user id so Bearer-authenticated endpoints can resolve the caller. Discord users linked to a GitHub account are stored under `discord-link:{discordUserId}`.
|
||||
`expiresAt` is a Unix timestamp in milliseconds. KV entries expire at 90% of the token's lifetime (minimum 60 seconds). A reverse index `token-reverse:{sha256 of token}` maps the access token back to its user id so Bearer-authenticated endpoints can resolve the caller. Discord users linked to a GitHub account are stored in the D1 `discord_links` table.
|
||||
|
||||
## Using Tokens
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ src/
|
|||
│ └── telegram/ # TelegramDriver stub (not implemented yet)
|
||||
├── github/ # GitHub OAuth + as-user actions
|
||||
│ ├── oauth.ts # OAuth URL, callback token exchange, getUserOctokit, actions
|
||||
│ └── store.ts # KV-based token CRUD + discord-link mapping
|
||||
│ └── store.ts # KV token CRUD + D1 discord-link mapping
|
||||
├── web/ # HTTP UI/API routes
|
||||
│ ├── oauth-routes.ts # GET /auth/github, callback, DELETE /token/:userId (KV state)
|
||||
│ ├── action-routes.ts # POST /api/comment|merge|close|react (Bearer token auth via KV lookup)
|
||||
|
|
@ -48,7 +48,7 @@ src/
|
|||
│ └── legal-routes.ts # Legal page routes
|
||||
└── lib/ # Shared infrastructure
|
||||
├── i18n.ts # Message language overrides (en/zh)
|
||||
├── send-log.ts # Send logging (logs:send KV keys)
|
||||
├── send-log.ts # Send logging (D1 send_logs)
|
||||
├── log.ts # JSON console logger (info/warn/error/fatal)
|
||||
└── locales/ # en.ts, zh.ts translation dictionaries
|
||||
```
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ Token 以键模式 `token:{userId}` 存储在 KV 中:
|
|||
}
|
||||
```
|
||||
|
||||
`expiresAt` 是毫秒级 Unix 时间戳。KV 条目在 Token 有效期的 90% 时过期(至少 60 秒)。反向索引 `token-reverse:{sha256 of token}` 将访问令牌映射回用户 id,使 Bearer 鉴权的端点能解析调用者。与 GitHub 账号绑定的 Discord 用户存储在 `discord-link:{discordUserId}` 下。
|
||||
`expiresAt` 是毫秒级 Unix 时间戳。KV 条目在 Token 有效期的 90% 时过期(至少 60 秒)。反向索引 `token-reverse:{sha256 of token}` 将访问令牌映射回用户 id,使 Bearer 鉴权的端点能解析调用者。与 GitHub 账号绑定的 Discord 用户存储在 D1 的 `discord_links` 表中。
|
||||
|
||||
## 使用 Token
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ src/
|
|||
│ └── telegram/ # TelegramDriver 占位(未实现)
|
||||
├── github/ # GitHub OAuth + 以用户身份操作
|
||||
│ ├── oauth.ts # OAuth URL、回调 Token 交换、getUserOctokit、操作
|
||||
│ └── store.ts # 基于 KV 的 Token CRUD + discord-link 映射
|
||||
│ └── store.ts # KV Token CRUD + D1 discord-link 映射
|
||||
├── web/ # HTTP UI/API 路由
|
||||
│ ├── oauth-routes.ts # GET /auth/github、回调、DELETE /token/:userId (KV 状态)
|
||||
│ ├── action-routes.ts # POST /api/comment|merge|close|react (通过 KV 查找进行 Bearer Token 鉴权)
|
||||
|
|
@ -48,7 +48,7 @@ src/
|
|||
│ └── legal-routes.ts # 法律页面路由
|
||||
└── lib/ # 共享基础设施
|
||||
├── i18n.ts # 消息语言覆盖 (en/zh)
|
||||
├── send-log.ts # 发送日志 (logs:send KV 键)
|
||||
├── send-log.ts # 发送日志 (D1 send_logs)
|
||||
├── log.ts # JSON 控制台日志 (info/warn/error/fatal)
|
||||
└── locales/ # en.ts、zh.ts 翻译字典
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue