Add ShareMetadata type and fix middleware type safety#151
Merged
Conversation
- Add ShareMetadata interface to types.d.ts for share link metadata - Replace `any` type in getShareLink.ts with ShareMetadata - Type parsed JSON in listShares.ts with ShareMetadata - Type share metadata object in createShareLink.ts with ShareMetadata - Fix readOnlyMiddleware to use Hono's Next type instead of CallableFunction
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
r2-explorer-docs | 79e340e | Commit Preview URL Branch Preview URL |
Mar 09 2026, 04:07 PM |
G4brym
commented
Mar 9, 2026
Owner
Author
G4brym
left a comment
There was a problem hiding this comment.
Automated Code Review — APPROVED ✅
Review Scores: 5/5 reviewers approved
CI Status: All checks passed ✅
Summary
Type-only refactor adding a ShareMetadata interface that replaces any across the share link modules, plus a fix to use Hono's Next type in readOnlyMiddleware. The type definition exactly matches the object shape created in createShareLink.ts, and all property accesses in getShareLink.ts and listShares.ts align correctly. No runtime behavior changes.
Review Perspectives
- Correctness: ✅ ShareMetadata type matches creation shape and all access patterns; optional/required fields are correct
- Security: ✅ No runtime changes, no new attack surfaces
- Performance: ✅ Types compile away, zero runtime impact
- Code Quality: ✅ Single source of truth for metadata shape, follows existing conventions, clean diff
- Testing: ✅ All 82 tests pass, no behavior changes requiring new tests
🤖 Automated review by prodboard
This was referenced Mar 9, 2026
Merged
This was referenced Mar 22, 2026
This was referenced Mar 30, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ShareMetadatatype interface totypes.d.tsthat defines the structure of share link metadata stored in R2anyingetShareLink.tswith the newShareMetadatatype, improving type safety when accessing share metadata properties (expiresAt,maxDownloads,passwordHash, etc.)listShares.tswithShareMetadatafor consistent typing across share link modulescreateShareLink.tsto ensure it conforms to theShareMetadatainterface at creation timereadOnlyMiddlewareto use Hono'sNexttype instead ofCallableFunction, which is the correct type for Hono middlewareWhy
The share link metadata was being created with a well-defined structure in
createShareLink.ts, but consumed asanyingetShareLink.tsand implicitly untyped inlistShares.ts. This meant there was no compile-time checking that the code accessing metadata properties (likeexpiresAt,passwordHash,currentDownloads) was correct. The newShareMetadatatype provides a single source of truth for the metadata shape.Test plan
pnpm lintpasses with no issuestsctype checking passes