Fix version restore endpoint by passing fileId through route and client API#32
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix POST /api/files/restore/:versionId to correctly extract file ID
Fix version restore endpoint by passing fileId through route and client API
Jun 5, 2026
Owner
|
@copilot resolve the merge conflicts in this pull request |
Owner
|
.. |
Closed
Contributor
Author
Resolved and finalized the merge conflicts in commit |
There was a problem hiding this comment.
Pull request overview
This PR updates the documented restore-version API shape and adds a route-level rate limit to the backend restore endpoint, along with the required backend dependency updates.
Changes:
- Updated README and controller comment to reflect
POST /api/files/restore/:fileId/:versionId. - Added
express-rate-limit-based throttling middleware to the restore route. - Added
express-rate-limit(and transitiveip-address) to backend dependencies/lockfile.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Readme.md | Syncs API reference + flow diagram to the restore route shape with fileId and versionId. |
| backend/routes/fileRoutes.js | Adds route-level rate limiting middleware on restore requests. |
| backend/package.json | Adds express-rate-limit dependency. |
| backend/package-lock.json | Locks express-rate-limit and transitive dependency versions. |
| backend/controllers/versionController.js | Updates the route header comment for restore to include :fileId/:versionId. |
Files not reviewed (1)
- backend/package-lock.json: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| router.post('/:fileId/version', verifyFileAccess, checkRole('editor'), saveVersion); | ||
| router.get('/:fileId/history', verifyFileAccess, getHistory); | ||
| router.post('/restore/:fileId/:versionId', verifyFileAccess, checkRole('editor'), restoreVersion); | ||
| router.post('/restore/:fileId/:versionId', restoreVersionRateLimit, verifyFileAccess, checkRole('editor'), restoreVersion); |
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.
Version restore was failing before controller execution because
verifyFileAccessonly acceptsid|fileId, while restore exposed only:versionId. This change aligns restore routing with access middleware so restore requests authorize correctly and reachrestoreVersion.API contract alignment (backend)
POST /api/files/restore/:versionIdPOST /api/files/restore/:fileId/:versionIdverifyFileAccesscan resolve the target file.Client integration update (frontend)
restoreVersionAPI helper signature to accept(fileId, versionId).VersionHistoryrestore action to pass currentfileIdwith selectedversionId.Documentation sync
Restore endpoint hardening