This project is a web application built using Cloudflare Workers and the Hono framework. It allows users to fetch and view code from GitHub repositories directly in their browser, consolidated into a single page. It supports filtering by directory and extension, viewing specific branches or single files, and even provides a directory tree view.
- ๐ Accepts various GitHub repository URL formats (including
/tree/and/blob/paths). - ๐ณ Automatically extracts branch, directory, and file information from the URL path.
- ๐ Filters files by directory paths and extensions using query parameters (
dir,ext). - ๐ฏ Displays a specific single file using the
filequery parameter or/blob/URL path. - ๐ฒ Offers a "Tree Mode" (
mode=tree) to show only the directory structure and README files. - ๐พ Handles large files by truncating content over 30KB and indicating the truncation.
- ๐ซ Skips binary files, lock files, and certain generated files (like
.jsin TS projects) for a cleaner view. - โจ Includes a custom favicon (
favicon.svg). - ๐ Fast processing using Cloudflare Workers.
- ๐ Accessible from anywhere.
- ๐จ Lightweight and efficient.
The application interprets GitHub URLs provided in the path after your worker domain. Query parameters can be used for further customization and override information extracted from the path.
Base URL: https://your-worker-domain/
Supported Path Formats:
-
Repository Root (Default Branch):
https://your-worker-domain/github.com/owner/repo(Attempts
mainbranch, thenmaster) -
Specific Branch (Tree View):
https://your-worker-domain/github.com/owner/repo/tree/branch-name -
Directory within a Branch (Tree View):
https://your-worker-domain/github.com/owner/repo/tree/branch-name/path/to/dir(Implicitly sets
dir=path/to/dir) -
Single File (Blob View):
https://your-worker-domain/github.com/owner/repo/blob/branch-name/path/to/file.ext(Implicitly sets
file=path/to/file.ext) -
Directory in Default Branch:
https://your-worker-domain/github.com/owner/repo/path/to/dir(Attempts
main/master, implicitly setsdir=path/to/dir)
Append these to the URL to customize the output. Query parameters override values derived from the URL path (e.g., ?branch=... overrides the branch from /tree/...).
dir: Filter files by directory paths (comma-separated).?dir=src/components,tests/unitext: Filter files by extensions (comma-separated, without dots).?ext=ts,tsx,jsmode: Display mode.?mode=tree # Shows directory structure and READMEs onlybranch: Specify the repository branch. Overrides branch from URL path.?branch=developfile: Specify a single file to display. Overrides file from URL path.?file=src/index.js
# Show all files in the 'main' branch of kazuph/github-pera1-workers
https://your-worker-domain/github.com/kazuph/github-pera1-workers
# Show files in the 'src' directory of the 'develop' branch
https://your-worker-domain/github.com/owner/repo/tree/develop/src
# OR
https://your-worker-domain/github.com/owner/repo?branch=develop&dir=src
# Show only TypeScript files in the 'src' directory
https://your-worker-domain/github.com/owner/repo?dir=src&ext=ts,tsx
# Show the directory structure and READMEs only
https://your-worker-domain/github.com/owner/repo?mode=tree
# Show a single file from the 'feat/new-ui' branch
https://your-worker-domain/github.com/owner/repo/blob/feat/new-ui/components/Button.jsx
# OR
https://your-worker-domain/github.com/owner/repo?branch=feat/new-ui&file=components/Button.jsx
- ๐ Cloudflare Workers
- โก Hono (Fast Web Framework)
- ๐ฆ JSZip (ZIP file manipulation)
- ๐ง TypeScript
- Node.js (check
.nvmrcif using nvm) - pnpm (or npm/yarn)
- Wrangler CLI (
pnpm install -g wranglerornpm install -g wrangler)
pnpm install
# or npm install / yarn installpnpm dev
# or npm run dev / yarn devThis will start a local server using wrangler dev.
pnpm deploy
# or npm run deploy / yarn deployThis command (defined in package.json) runs wrangler deploy.
- Node.js
- pnpm (recommended)
- wrangler CLI
(See package.json for exact versions)
- hono
- jszip
- wrangler (dev dependency)
- typescript (dev dependency)
- @cloudflare/workers-types (dev dependency)