RSSHub/lib/utils
DIYgod 1131350b5f
feat: deploy RSSHub to Cloudflare Workers (#20804)
* feat: deploy RSSHub to Cloudflare Workers

- Create Worker entry point (lib/worker.ts) with polyfills
- Implement Worker-specific app configuration (lib/app.worker.tsx)
- Add automatic .worker.ts resolution plugin for cleaner config
- Simplify build configuration with only 3 essential shims
- Enable static asset serving via Cloudflare Static Assets feature
- Support dynamic route loading with proper module aliasing

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* feat(worker): add puppeteer and request-rewriter support

- Add @cloudflare/puppeteer for Browser Rendering API support
- Create puppeteer.worker.ts with Cloudflare Browser binding
- Add request-rewriter Worker version with static browser headers
- Add vm module shim to node-module.ts for JSDOM compatibility
- Configure __dirname/__filename in tsdown for CommonJS compat
- Update wrangler.toml with BROWSER binding configuration
- Dynamically extract namespaces from foloAnalysisTop100 for routes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(cache): restore synchronous initialization for tests

The async initialization caused cache tests to fail because the cache
module wasn't ready when tests ran. Restored synchronous imports while
keeping Worker-specific no-op behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(worker): add automated Worker integration tests

- Add miniflare for Worker environment simulation
- Create lib/worker.worker.test.ts with integration tests
- Test basic routes (/test/1, /, unknown routes)
- Test RSS feed routes (hackernews, v2ex)
- Test error handling for puppeteer routes without BROWSER binding
- Add worker-test npm script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(worker): use test routes for Worker integration tests

- Replace third-party routes (hackernews, v2ex, weibo) with /test/* routes
- Remove miniflare dependency (wrangler includes it internally)
- Simplify test setup using wrangler's unstable_dev API

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(test): make header-generator test less flaky

The header-generator library may return different platform values due to
internal randomness. Update test to check for valid format instead of
exact value.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(test): exclude worker tests from vitest coverage run

Worker tests require the dist-worker bundle to be built first,
which is not part of the regular CI test workflow. These tests
should be run separately using 'pnpm worker-test'.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(worker): add automated Worker integration tests

- Add worker-build step to CI workflow before running tests
- Revert exclusion of worker tests from vitest coverage run
- Worker tests now run as part of the regular test suite

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(worker): fix routes.js alias path in worker build config

Change alias key from absolute path to relative import path to match
how it's imported in lib/registry.ts. This fixes the worker build
failing with "Could not resolve '../assets/build/routes.js'" error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* ci: trigger CI re-run

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(ci): build worker routes before worker-build

The worker build requires routes-worker.js which is generated by
running build:routes with WORKER_BUILD=true. This was missing in CI,
causing the worker build to fail with "Could not resolve routes.js".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(test): increase timeout for Worker integration tests

Worker tests need more time in CI environments. Increase individual
test timeouts from default 10s to 30s for each test case.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-04 09:22:05 +08:00
..
cache feat: deploy RSSHub to Cloudflare Workers (#20804) 2026-01-04 09:22:05 +08:00
otel feat: deploy RSSHub to Cloudflare Workers (#20804) 2026-01-04 09:22:05 +08:00
proxy feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
request-rewriter feat: deploy RSSHub to Cloudflare Workers (#20804) 2026-01-04 09:22:05 +08:00
cache.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
camelcase-keys.spec.ts refactor: fix lint issue (#18963) 2025-04-29 03:00:16 +08:00
camelcase-keys.ts refactor: fix all no array reduce (#18973) 2025-04-30 04:16:32 +08:00
common-config.charset.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
common-config.test.ts style: auto format 2025-11-27 02:55:46 +00:00
common-config.ts style: auto format 2025-11-27 02:55:46 +00:00
common-utils.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
common-utils.ts style: auto format 2025-11-27 02:55:46 +00:00
debug-info.ts
directory-import.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
directory-import.ts refactor: replace art template with jsx (#20777) 2025-12-29 12:27:32 +08:00
directory-import.worker.ts feat: deploy RSSHub to Cloudflare Workers (#20804) 2026-01-04 09:22:05 +08:00
git-hash.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
git-hash.ts style: auto format 2025-11-27 02:55:46 +00:00
got.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
got.ts style: auto format 2025-11-27 02:55:46 +00:00
header-generator.mock.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
header-generator.test.ts feat: deploy RSSHub to Cloudflare Workers (#20804) 2026-01-04 09:22:05 +08:00
header-generator.ts style: auto format 2025-11-27 05:54:33 +00:00
helpers.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
helpers.ts style: auto format 2025-11-27 02:55:46 +00:00
is-worker.ts feat: deploy RSSHub to Cloudflare Workers (#20804) 2026-01-04 09:22:05 +08:00
is-worker.worker.ts feat: deploy RSSHub to Cloudflare Workers (#20804) 2026-01-04 09:22:05 +08:00
logger.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
logger.ts style: replace unicorn/no-for-loop w/ typescript/prefer-for-of (#20798) 2026-01-02 09:42:24 +08:00
logger.worker.ts feat: deploy RSSHub to Cloudflare Workers (#20804) 2026-01-04 09:22:05 +08:00
md5.test.ts style: auto format 2025-11-27 02:55:46 +00:00
md5.ts refactor: fix lint issue (#18963) 2025-04-29 03:00:16 +08:00
ofetch.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
ofetch.ts style: auto format 2025-11-27 02:55:46 +00:00
parse-date.test.ts style: auto format 2025-11-27 02:55:46 +00:00
parse-date.ts feat: compile ts through tsdown (#18908) 2025-04-22 22:29:11 +08:00
puppeteer-utils.test.ts style: auto format 2025-11-27 02:55:46 +00:00
puppeteer-utils.ts style: auto format 2025-11-27 02:55:46 +00:00
puppeteer.mock.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
puppeteer.test.ts style: auto format 2025-11-27 05:54:33 +00:00
puppeteer.ts style: auto format 2025-11-27 02:55:46 +00:00
puppeteer.worker.ts feat: deploy RSSHub to Cloudflare Workers (#20804) 2026-01-04 09:22:05 +08:00
readable-social.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
readable-social.ts style: auto format 2025-11-27 02:55:46 +00:00
render.ts refactor: replace art template with jsx (#20777) 2025-12-29 12:27:32 +08:00
request-rewriter.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
rss-parser.test.ts style: auto format 2025-11-27 02:55:46 +00:00
rss-parser.ts style: auto format 2025-11-27 02:55:46 +00:00
timezone.test.ts feat(tests): add comprehensive unit tests for various utility functions and views (#20779) 2025-12-29 17:34:48 +08:00
timezone.ts refactor: fix lint issue (#18963) 2025-04-29 03:00:16 +08:00
valid-host.test.ts style: auto format 2025-11-27 02:55:46 +00:00
valid-host.ts
wait.test.ts style: auto format 2025-11-27 02:55:46 +00:00
wait.ts
wechat-mp.test.ts style: auto format 2026-01-02 01:44:18 +00:00
wechat-mp.ts style: auto format 2026-01-02 01:44:18 +00:00