[PR #683] [MERGED] refactor: extract Pages API route runtime #768

Closed
opened 2026-05-06 13:10:01 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/683
Author: @southpolesteve
Created: 3/25/2026
Status: Merged
Merged: 3/28/2026
Merged by: @james-elicx

Base: mainHead: codex/pages-api-route-runtime


📝 Commits (3)

  • 89361bb refactor: extract pages api route runtime
  • 740d479 refactor: share Pages ISR cache runtime (#684)
  • a8f925e fix: address Pages API route review feedback

📊 Changes

8 files changed (+717 additions, -539 deletions)

View changed files

📝 packages/vinext/src/entries/pages-server-entry.ts (+40 -252)
📝 packages/vinext/src/server/api-handler.ts (+6 -28)
packages/vinext/src/server/pages-api-route.ts (+82 -0)
packages/vinext/src/server/pages-media-type.ts (+25 -0)
packages/vinext/src/server/pages-node-compat.ts (+263 -0)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+30 -252)
📝 tests/entry-templates.test.ts (+33 -7)
tests/pages-api-route.test.ts (+238 -0)

📄 Description

Summary

  • move the Pages Router API route request/body parsing and Node-style req/res facade into typed server helpers
  • keep pages-server-entry.ts focused on generated wiring by delegating API route execution to handlePagesApiRoute
  • add direct helper coverage for duplicate query/body keys, invalid JSON, oversized bodies, and Buffer responses

Verification

  • vp check packages/vinext/src/server/pages-node-compat.ts packages/vinext/src/server/pages-api-route.ts packages/vinext/src/entries/pages-server-entry.ts tests/pages-api-route.test.ts tests/entry-templates.test.ts
  • vp test run tests/pages-api-route.test.ts tests/entry-templates.test.ts
  • vp test run tests/pages-router.test.ts -t "handles API routes returning JSON|handles dynamic API routes with query params|returns 400 for invalid JSON bodies on Pages API routes|preserves duplicate urlencoded body keys on Pages API routes|sends Buffer payloads from res.send\(\) as raw bytes|preserves invalid JSON failures for Pages API routes in production|preserves duplicate urlencoded body keys for Pages API routes in production|parses empty JSON bodies for Pages API routes in production as \{}|sends Buffer payloads from res.send\(\) as raw bytes in production|preserves content-length for getServerSideProps res.end\(\) short-circuit responses in production"
  • vp run vinext#build

Written by Codex.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/683 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 3/25/2026 **Status:** ✅ Merged **Merged:** 3/28/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `codex/pages-api-route-runtime` --- ### 📝 Commits (3) - [`89361bb`](https://github.com/cloudflare/vinext/commit/89361bbcb14b589bed68a3b689d18845d5ebfd85) refactor: extract pages api route runtime - [`740d479`](https://github.com/cloudflare/vinext/commit/740d479c9283a3466e272baa7eb268dee228c51b) refactor: share Pages ISR cache runtime (#684) - [`a8f925e`](https://github.com/cloudflare/vinext/commit/a8f925e8fdfe88ff099a6a1f3a50f54de90359f6) fix: address Pages API route review feedback ### 📊 Changes **8 files changed** (+717 additions, -539 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/pages-server-entry.ts` (+40 -252) 📝 `packages/vinext/src/server/api-handler.ts` (+6 -28) ➕ `packages/vinext/src/server/pages-api-route.ts` (+82 -0) ➕ `packages/vinext/src/server/pages-media-type.ts` (+25 -0) ➕ `packages/vinext/src/server/pages-node-compat.ts` (+263 -0) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+30 -252) 📝 `tests/entry-templates.test.ts` (+33 -7) ➕ `tests/pages-api-route.test.ts` (+238 -0) </details> ### 📄 Description ## Summary - move the Pages Router API route request/body parsing and Node-style req/res facade into typed server helpers - keep `pages-server-entry.ts` focused on generated wiring by delegating API route execution to `handlePagesApiRoute` - add direct helper coverage for duplicate query/body keys, invalid JSON, oversized bodies, and Buffer responses ## Verification - `vp check packages/vinext/src/server/pages-node-compat.ts packages/vinext/src/server/pages-api-route.ts packages/vinext/src/entries/pages-server-entry.ts tests/pages-api-route.test.ts tests/entry-templates.test.ts` - `vp test run tests/pages-api-route.test.ts tests/entry-templates.test.ts` - `vp test run tests/pages-router.test.ts -t "handles API routes returning JSON|handles dynamic API routes with query params|returns 400 for invalid JSON bodies on Pages API routes|preserves duplicate urlencoded body keys on Pages API routes|sends Buffer payloads from res.send\(\) as raw bytes|preserves invalid JSON failures for Pages API routes in production|preserves duplicate urlencoded body keys for Pages API routes in production|parses empty JSON bodies for Pages API routes in production as \{}|sends Buffer payloads from res.send\(\) as raw bytes in production|preserves content-length for getServerSideProps res.end\(\) short-circuit responses in production"` - `vp run vinext#build` Written by Codex. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:10:01 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#768
No description provided.