-
Notifications
You must be signed in to change notification settings - Fork 2
Add cache handlers package #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ascorbic
wants to merge
31
commits into
main
Choose a base branch
from
add-cache-handlers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 13 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
2bdb1df
chore: move to monorepo
ascorbic 713b7af
feat: add cache-handlers
ascorbic 7367941
Add claude
ascorbic 6092b3e
Deno fixes
ascorbic 17da6ab
tidy up
ascorbic 397b1e9
Update
ascorbic af9b927
swr
ascorbic 17558f3
wip
ascorbic 1a2690d
wip
ascorbic eee4cd2
wip
ascorbic 0da730d
Use deno for formatting
ascorbic 704de8c
Use deno for checks
ascorbic bbddefe
revert changes for cdn cache control package
ascorbic f08e88b
lock
ascorbic 3b87be0
Merge branch 'main' into add-cache-handlers
ascorbic b4f460f
Potential fix for code scanning alert no. 2: Workflow does not contai…
ascorbic 5ae4573
Add deno to actions
ascorbic e1fdbc6
Potential fix for code scanning alert no. 4: Incomplete URL substring…
ascorbic 8259dec
Update tests and types
ascorbic 06d3f72
More test updates
ascorbic 5197069
Update
ascorbic 90da8f9
package.json fixes
ascorbic 825492b
Add cache status
ascorbic 2a337c4
Add demo and fix types
ascorbic 4e51487
Add debug logging
ascorbic 119004b
Simplify types
ascorbic 001931b
No wrangler conf
ascorbic 47b7577
Add wrangler.jsonc
ascorbic 22f0d02
assetsignore
ascorbic a1941cd
Handle difference between max-age and s-maxage
ascorbic 7d6c604
Update tests
ascorbic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| # Changesets | ||
|
|
||
| Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
| with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
| find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
| Hello and welcome! This folder has been automatically generated by | ||
| `@changesets/cli`, a build tool that works with multi-package repos, or | ||
| single-package repos to help you version and publish your code. You can find the | ||
| full documentation for it | ||
| [in our repository](https://github.com/changesets/changesets) | ||
|
|
||
| We have a quick list of common questions to get you started engaging with this project in | ||
| We have a quick list of common questions to get you started engaging with this | ||
| project in | ||
| [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ | |
| "baseBranch": "main", | ||
| "updateInternalDependencies": "patch", | ||
| "ignore": [] | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| name: Claude PR Assistant | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issues: | ||
| types: [opened, assigned] | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| jobs: | ||
| claude-code-action: | ||
| if: | | ||
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | ||
| (github.event_name == 'issues' && contains(github.event.issue.body, '@claude')) | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| issues: read | ||
| id-token: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "lts/*" | ||
| cache: "pnpm" | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Run Claude PR Action | ||
| uses: anthropics/claude-code-action@beta | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
| timeout_minutes: "5" | ||
| # mcp_config: | | ||
| # { | ||
| # "mcpServers": { | ||
| # "astro-docs": { | ||
| # "type": "http", | ||
| # "url": "https://mcp.docs.astro.build/mcp" | ||
| # } | ||
| # } | ||
| # } | ||
| allowed_tools: | | ||
| Bash(pnpm install) | ||
| Bash(pnpm run:*) | ||
| Bash(npm run:*) | ||
| Bash(npx packages/am-i-vibing) | ||
| # mcp__astro-docs__search_astro_docs | ||
| # Optional: Restrict network access to specific domains only | ||
| # experimental_allowed_domains: | | ||
| # .anthropic.com | ||
| # .github.com | ||
| # api.github.com | ||
| # .githubusercontent.com | ||
| # bun.sh | ||
| # registry.npmjs.org | ||
| # .blob.core.windows.net |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: "Lint PR" | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: | ||
| - opened | ||
| - edited | ||
| - synchronize | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| main: | ||
| name: Validate PR title | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: amannn/action-semantic-pull-request@v5 | ||
| with: | ||
| types: | | ||
| fix | ||
| feat | ||
| chore | ||
| docs | ||
| ci | ||
| test | ||
| revert | ||
| id: lint_pr_title | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - uses: marocchino/sticky-pull-request-comment@v2 | ||
| # When the previous steps fails, the workflow would stop. By adding this | ||
| # condition you can continue the execution with the populated error message. | ||
| if: always() && (steps.lint_pr_title.outputs.error_message != null) | ||
| with: | ||
| header: pr-title-lint-error | ||
| message: | | ||
| Hey there and thank you for opening this pull request! 👋🏼 | ||
|
|
||
| We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. | ||
| Without this title format, a release will not be triggered | ||
|
|
||
| Details: | ||
|
|
||
| ``` | ||
| ${{ steps.lint_pr_title.outputs.error_message }} | ||
| ``` | ||
|
|
||
| # Delete a previous comment when the issue has been resolved | ||
| - if: ${{ steps.lint_pr_title.outputs.error_message == null }} | ||
| uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| header: pr-title-lint-error | ||
| delete: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Test | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [main] | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - uses: pnpm/action-setup@v2 | ||
| with: | ||
| version: 8 | ||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| cache: "pnpm" | ||
| check-latest: true | ||
| registry-url: "https://registry.npmjs.org" | ||
| - name: Install dependencies | ||
| run: | | ||
| corepack enable | ||
| pnpm install | ||
| - name: Build | ||
| run: pnpm build | ||
| - name: Test | ||
| run: pnpm test | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| package.json | ||
| CHANGELOG.md | ||
| pnpm-lock.yaml | ||
| **/deno/**/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| {} | ||
| { | ||
| "useTabs": true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,17 @@ | ||
| { | ||
| "typescript.tsdk": "node_modules/typescript/lib" | ||
| } | ||
| "typescript.tsdk": "node_modules/typescript/lib", | ||
| "deno.enablePaths": [ | ||
| "packages/cache-handlers/" | ||
| ], | ||
| "deno.config": "./deno.json", | ||
| "deno.suggest.imports.hosts": { | ||
| "https://deno.land": true, | ||
| "https://jsr.io": true | ||
| }, | ||
| "[typescript]": { | ||
| "editor.defaultFormatter": "denoland.vscode-deno" | ||
| }, | ||
| "[javascript]": { | ||
| "editor.defaultFormatter": "denoland.vscode-deno" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with | ||
| code in this repository. | ||
|
|
||
| ## Repository Structure | ||
|
|
||
| This is a monorepo for CDN cache control libraries using pnpm workspaces: | ||
|
|
||
| - **Root**: Workspace configuration and shared tooling | ||
| - **packages/**: Individual library packages | ||
| - `cdn-cache-control`: Easy, opinionated CDN cache header handling (TypeScript | ||
| class-based API) | ||
| - `cache-handlers`: Modern CDN cache primitives using web-standard middleware | ||
| (functional API) | ||
|
|
||
| ## Commands | ||
|
|
||
| ### Root-level commands (run from repository root): | ||
|
|
||
| - `pnpm build` - Build all packages | ||
| - `pnpm test` - Run tests for all packages (includes Deno, Node.js, and Workerd | ||
| tests) | ||
| - `pnpm check` - Run type checking and linting for all packages | ||
| - `pnpm lint` - Run linting for all packages | ||
| - `pnpm format` - Format code using Prettier | ||
|
|
||
| ### Package-level commands (run within individual packages): | ||
|
|
||
| - `pnpm build` - Build the package using tsdown (ESM + DTS output) | ||
| - `pnpm dev` - Watch mode for development | ||
| - `pnpm test` - Run tests (specific to each package's test setup) | ||
| - `pnpm check` - Run publint and @arethetypeswrong/cli checks | ||
|
|
||
| ### Test-specific commands for cache-handlers package: | ||
|
|
||
| - `pnpm test:deno` - Run Deno tests from repository root | ||
| - `pnpm test:node` - Run Node.js tests via Vitest | ||
| - `pnpm test:workerd` - Run Cloudflare Workers tests via Vitest | ||
|
|
||
| ## Development Workflow | ||
|
|
||
| - Uses **pnpm** as package manager | ||
| - **tsdown** for building TypeScript packages with ESM output and declaration | ||
| files | ||
| - **deno** for testing | ||
| - **publint** and **@arethetypeswrong/cli** for package validation | ||
| - **Prettier** for code formatting (configured to use tabs in `.prettierrc`) | ||
|
|
||
| ## Package Architecture | ||
|
|
||
| ### cdn-cache-control | ||
|
|
||
| - **API Style**: Class-based (`CacheHeaders` extends `Headers`) | ||
| - **Target**: Simple cache header management with CDN-specific optimizations | ||
| - **Testing**: Node.js only via `node --test` | ||
| - **Build**: ESM + CommonJS outputs | ||
|
|
||
| ### cache-handlers | ||
|
|
||
| - **API Style**: Functional middleware approach | ||
| - **Target**: Web standard cache primitives for modern applications | ||
| - **Key Features**: | ||
| - Factory functions (`createCacheHandlers`, `createReadHandler`, etc.) | ||
| - HTTP conditional requests (ETag, Last-Modified, 304 responses) | ||
| - Cache invalidation by tags and paths | ||
| - Multi-runtime support (Deno, Node.js, Cloudflare Workers) | ||
| - **Testing**: Multi-runtime (Deno tests, Node.js via Vitest, Workerd via | ||
| Vitest) | ||
| - **Build**: ESM-only output | ||
|
|
||
| Each package follows this structure: | ||
|
|
||
| - `src/index.ts` - Main entry point with comprehensive exports | ||
| - `test/` - Test files (runtime-specific subdirectories for cache-handlers) | ||
| - `dist/` - Built output (ESM + .d.ts files) | ||
| - Package exports configured for proper TypeScript declarations | ||
|
|
||
| ## TypeScript Configuration | ||
|
|
||
| Uses strict TypeScript configuration with: | ||
|
|
||
| - Target: ES2022 | ||
| - Module: preserve (for bundler compatibility) | ||
| - Strict mode with additional safety checks (`noUncheckedIndexedAccess`, | ||
| `noImplicitOverride`) | ||
| - Library-focused settings (declaration files, declaration maps) | ||
|
|
||
| ## Use Specialized Agents for Complex Tasks | ||
|
|
||
| ALWAYS use the appropriate specialized agents for complex work: | ||
|
|
||
| - **technical-architect**: For designing system architecture, evaluating | ||
| technical approaches, planning major features | ||
| - **code-reviewer**: For comprehensive code review after implementing | ||
| significant code changes | ||
| - **test-engineer**: For analyzing test failures, creating new tests, and | ||
| enhancing test coverage. Should NOT fix application code - only | ||
| creates/updates test files | ||
| - **docs-author**: For creating or updating documentation, READMEs, changesets, | ||
| or PR descriptions | ||
| - **package-installer**: For installing npm packages with proper dependency | ||
| management |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.