Skip to content

feat: auto-wrap plain object route returns in Response.json()#49

Open
CelebrityPunks wants to merge 1 commit intotscircuit:mainfrom
CelebrityPunks:feat/auto-json-response
Open

feat: auto-wrap plain object route returns in Response.json()#49
CelebrityPunks wants to merge 1 commit intotscircuit:mainfrom
CelebrityPunks:feat/auto-json-response

Conversation

@CelebrityPunks
Copy link

Summary

When a route returns a plain object (return { foo: "bar" }) instead of Response.json(...), winterspec now auto-wraps it in Response.json() instead of throwing an error. This makes route handlers more convenient.

Changes

  • src/middleware/with-response-object-check.ts: Changed from throwing error to returning Response.json(rawResponse)
  • tests/errors/do-not-allow-raw-json.test.ts: Updated test to verify auto-wrapping behavior

Closes #30

🤖 Generated with Claude Code

Instead of throwing when a route returns a plain object,
auto-wrap it in Response.json() for developer convenience.

Closes tscircuit#30

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When a user returns return { ... } from a route instead of return ctx.json({ ... }), throw an error telling them to use ctx.json

2 participants