Footer hash#9
Conversation
📝 WalkthroughWalkthroughAdds three new utilities and integrates them into the worker. src/utils/github-api.ts provides a GitHub client with caching, parsing, and latest-commit retrieval. src/utils/app-registry.ts implements a pattern-to-repo registry with manual and auto-detection, positive/negative caching, and APIs to initialize, register, query, preload, and clear entries. src/utils/html-injector.ts builds footer HTML/CSS, decides injection eligibility, and injects a version footer into HTML responses. worker.ts wires registry initialization/preloading, exposes version metadata in logs, adds FOOTER_ENABLED, and conditionally injects footers into proxied HTML responses. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (2)
src/utils/html-injector.ts (1)
232-260:decompressBodycurrently returns compressed bytes.The name implies decompression but the function only concatenates chunks. If it’s used for gzip/br content later, the output will be invalid. Consider implementing decompression (e.g.,
DecompressionStream) or throw/rename to avoid silent misuse.🧭 Safer placeholder
- // Note: Full decompression would require additional libraries - // For Cloudflare Workers, we'd need to handle this differently - // This is a placeholder for the decompression logic - return combined; + throw new Error(`Decompression for ${encoding} not implemented`);src/utils/app-registry.ts (1)
467-479: Escape regex metacharacters in patterns.Dots in patterns are currently treated as wildcards. Escaping before replacing
*avoids over-matching.🔧 Suggested regex build
- const regex = new RegExp('^' + pattern.replace(/\*/g, '[^.]+') + '$'); + const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&'); + const regex = new RegExp('^' + escaped.replace(/\\\*/g, '[^.]+') + '$');
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
src/utils/github-api.ts (2)
137-142: DuplicategetShortHashfunction.Same function exists in
src/utils/html-injector.ts(lines 264-266). Consider exporting from one location.
144-169: In-memory cache lacks size limits.Cache can grow unbounded for long-running workers with many unique repos. Consider adding max entries or LRU eviction.
💡 Example: simple max-size cap
+const MAX_CACHE_SIZE = 1000; + function setCache(key: string, value: GitHubCommitInfo, ttlSeconds: number): void { + // Evict oldest entries if cache is full + if (cache.size >= MAX_CACHE_SIZE) { + const firstKey = cache.keys().next().value; + if (firstKey) cache.delete(firstKey); + } cache.set(key, { value, expiresAt: Date.now() + ttlSeconds * 1000, }); }src/utils/app-registry.ts (1)
40-353: Large static registry is verbose but functional.Consider extracting to a JSON/YAML config file for easier maintenance, but acceptable as-is for now.
|
@0x4007 would appreciate a review 🙏 |
fixes #6
I had some questions though -
RPC endpoint clarification
For https://rpc.ubq.fi/:chainId, could you please share the relevant GitHub repository where this RPC is defined so it can be correctly added to the app-registry mapping?
README typo
There appears to be a small typo in the README:
os--dev[elopment].ubq.fi
Should this consistently be os--development.ubq.fi?
Plugin deployment issue
Several plugin pages currently display a “deno not deployed” error.
Is this expected behavior (e.g., work in progress), or are these plugins supposed to be live?