Repository navigation
feat(api): POST /api/packages/upload (REST upload path) - #24
Merged
Merged
Conversation
…packages) The /account/tokens page advertises a curl/fetch snippet against POST /api/packages/upload, but the route did not exist — the SPA caught the unmatched path and returned HTML, leaving curl/CI users without a working write path. Adds the route with Bearer auth (sas_… PAT or OAuth access token) that reuses processBulkUpload, so REST and MCP share the same pipeline, queue, and private-draft semantics. `publish:true` is accepted in the body for forward compatibility but ignored — marketplace listing still requires the /account/packages submit flow + admin review. Also extracts verifyBearer/extractBearer into src/lib/auth/bearer.server.ts so /api/mcp and /api/packages/upload validate tokens identically. https://claude.ai/code/session_019gMoupKKTVydpNwiiACQRd
criptogus
marked this pull request as ready for review
May 23, 2026 03:35
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
/account/tokensadvertises a curl + JS snippet againstPOST /api/packages/upload, but the route didn't exist — the SPA caught it and returned HTML. CI / curl users had no working write path.Authorization: Bearer …auth (accepts bothsas_…PATs and OAuth access tokens) on top of the existingprocessBulkUploadpipeline, so REST and MCP share the same logic, queue, and private-draft semantics.publish: truein the body is accepted for forward-compat but ignored — marketplace listing still requires the explicit submit flow in/account/packagesfollowed by admin review.verifyBearer+extractBearerintosrc/lib/auth/bearer.server.tsso/api/mcpand/api/packages/uploadvalidate identically.mcp.tsnow imports from the shared util.Test plan
curl -i -X POST $HOST/api/packages/upload -H "Authorization: Bearer $SAS_TOKEN" -H "Content-Type: application/json" -d '{"files":[{"name":"x.md","content":"# hi"}]}'returns200withvisibility:"private_draft"and apackage_id.Authorizationreturns401JSON (no SPA HTML).401.queued.publish:truein the body still results in a private draft (and surfacespublish_ignoredhint).upload_packagesstill works (regression — sameverifyBearernow imported, not duplicated).https://claude.ai/code/session_019gMoupKKTVydpNwiiACQRd
Generated by Claude Code