归档 artalk-cf 评论后端 + rss-robot 到 blog-admin(含技术选型/模块分布 README)
Deploy to Production / pre-check (push) Successful in 58s
Deploy to Production / build (push) Successful in 4m3s
Deploy to Production / deploy-edgeone (push) Successful in 3m48s
Deploy to Production / finalize (push) Successful in 26s
Deploy to Production / notify-failure (push) Skipped

This commit is contained in:
zqlit committed 2026-10-04 08:45:40 +08:00
1 parent 855a001046
commit a74b3c7127
98 files changed
+15657

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# 部署后冒烟测试:把 BASE 换成你的 Worker 地址即可
# bash tools/smoke.sh https://artalk-cf.<你的子域>.workers.dev
set -uo pipefail
BASE="${1:-http://127.0.0.1:8787}"
SITE="${SITE:-优世界}"
PAGE_KEY="${PAGE_KEY:-/20210911.html}"
TOKEN="${TOKEN:-}"
# ★ 中文必须 percent-encode 再拼进 URL:直接发原始 UTF-8 字节,
# Cloudflare 边缘会把这行请求判成 400 Bad Request(空 body),看起来像服务端坏了。
# 浏览器里的 Artalk 客户端用 URLSearchParams 会自动编码,所以真实流量没这个问题。
enc() { node -e 'process.stdout.write(encodeURIComponent(process.argv[1]))' "$1"; }
SITE_Q=$(enc "$SITE")
PAGE_Q=$(enc "$PAGE_KEY")
pass=0
fail=0
chk() {
local name="$1"; shift
local expect="$1"; shift
local code
code=$(curl -s -o /tmp/atk_out -w '%{http_code}' "$@" --max-time 20)
if [ "$code" = "$expect" ]; then
printf ' \033[32mPASS\033[0m %-42s %s\n' "$name" "$code"
pass=$((pass + 1))
else
printf ' \033[31mFAIL\033[0m %-42s %s (期望 %s)\n' "$name" "$code" "$expect"
printf ' %s\n' "$(head -c 300 /tmp/atk_out)"
fail=$((fail + 1))
fi
}
echo "== 基础 =="
chk "GET /api/v2/healthz" 200 "$BASE/api/v2/healthz"
chk "GET /api/v2/version" 200 "$BASE/api/v2/version"
chk "GET /api/v2/conf" 200 "$BASE/api/v2/conf"
chk "GET /api/v2/conf/auth/providers" 200 "$BASE/api/v2/conf/auth/providers"
chk "OPTIONS 预检" 204 -X OPTIONS "$BASE/api/v2/comments" -H "Origin: https://usj.cc"
echo "== 评论读取 =="
chk "GET /api/v2/comments (page 作用域)" 200 "$BASE/api/v2/comments?page_key=$PAGE_Q&site_name=$SITE_Q&limit=5"
chk "GET /api/v2/comments (site 作用域)" 200 "$BASE/api/v2/comments?scope=site&site_name=$SITE_Q&limit=5"
chk "GET /api/v2/comments (搜索)" 200 "$BASE/api/v2/comments?scope=site&site_name=$SITE_Q&search=%E5%B0%8F%E8%B5%B5&limit=5"
chk "GET /api/v2/comments (不存在的站点)" 400 "$BASE/api/v2/comments?page_key=/x.html&site_name=__nope__"
echo "== 后台(未带 token 应 403) =="
chk "GET /api/v2/sites" 403 "$BASE/api/v2/sites"
chk "GET /api/v2/settings" 403 "$BASE/api/v2/settings"
chk "GET /api/v2/stats/site_comment" 403 "$BASE/api/v2/stats/site_comment"
chk "GET /api/v2/users/all" 403 "$BASE/api/v2/users/all"
if [ -n "$TOKEN" ]; then
echo "== 后台(带管理员 token) =="
chk "GET /api/v2/sites" 200 -H "Authorization: Bearer $TOKEN" "$BASE/api/v2/sites"
chk "GET /api/v2/settings" 200 -H "Authorization: Bearer $TOKEN" "$BASE/api/v2/settings"
chk "GET /api/v2/settings/template/zh-CN" 200 -H "Authorization: Bearer $TOKEN" "$BASE/api/v2/settings/template/zh-CN"
chk "GET /api/v2/stats/site_comment" 200 -H "Authorization: Bearer $TOKEN" "$BASE/api/v2/stats/site_comment"
chk "GET /api/v2/users/all" 200 -H "Authorization: Bearer $TOKEN" "$BASE/api/v2/users/all"
chk "GET /api/v2/pages" 200 -H "Authorization: Bearer $TOKEN" "$BASE/api/v2/pages"
chk "GET /api/v2/transfer/export" 200 -H "Authorization: Bearer $TOKEN" "$BASE/api/v2/transfer/export?site_name=$SITE_Q"
fi
echo
echo "通过 $pass / 失败 $fail"
[ "$fail" -eq 0 ]