feat: Add POST /echo endpoint with JSON round-trip#299
Open
RobertGuajardo wants to merge 2 commits intosnarktank:mainfrom
Open
feat: Add POST /echo endpoint with JSON round-trip#299RobertGuajardo wants to merge 2 commits intosnarktank:mainfrom
RobertGuajardo wants to merge 2 commits intosnarktank:mainfrom
Conversation
|
@RobertGuajardo is attempting to deploy a commit to the Ryan Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Review: ✅ Approved Clean, well-structured implementation. The streaming body collection, JSON parse/echo, and 400 error path are all correct. CORS header is applied consistently on both success and error responses. Tests: Cover the essential cases — valid JSON echo (simple and nested objects), invalid JSON returning 400, and GET method falling through to HTML. Each test starts its own isolated server on port 0, which is good for test isolation. Minor observations (non-blocking):
Overall: solid work. Shipping this. |
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
Adds a
POST /echoendpoint to the dashboard server that returns the request body as JSON.What
POST /echoContent-Type: application/jsonand HTTP 200{"error": "invalid JSON"}for empty or malformed bodiesAccess-Control-Allow-Origin: *header on all responses from this endpointFiles Changed
src/server/dashboard.ts— Added the/echoroute handler before the catch-all HTML responsetests/echo-endpoint.test.ts— 4 new tests covering: valid JSON echo, empty body 400, invalid JSON 400, and CORS header presenceTesting
All 166 unit/integration tests pass (0 failures), including the 4 new echo endpoint tests.
E2E curl testing against a live server on port 9999 verified:
Happy path: Simple objects, empty objects, deeply nested objects, Unicode/emoji, arrays at root, null/boolean/number/string values, large floats (1e308), large payloads (~1MB), and 50 concurrent requests all returned 200 with correct echoed body.
Error cases: Empty body, invalid JSON text, and truncated JSON all returned 400 +
{"error": "invalid JSON"}.Cross-cutting: CORS header present on both 200 and 400 responses;
Content-Type: application/jsonon all responses; permissive about incoming Content-Type header (by design for a test echo endpoint).Known gap: OPTIONS preflight returns 200 HTML (no CORS preflight headers) — acceptable for this internal testing endpoint.