feat(website): native ?renderJson support in the Fresh handler - #1612
feat(website): native ?renderJson support in the Fresh handler#1612marcoferreiradev wants to merge 2 commits into
Conversation
fresh.ts gains a structured-JSON exit alongside the existing ?asJson one:
?renderJson (legacy alias ?appJson — remove once consumers switch) resolves
the page with hooks that short-circuit sections opted out of JSON rendering
(their loaders never run), serializes the tree via @deco/deco
serializeResolvedSection honoring each section's `renderJson` export, and
responds { name, path, sections } with lazy sections as
{ component, lazyUrl } placeholders. One-shot JSON responses never use
async render (firstByteThreshold guards extended); renderJson takes
precedence when both params are sent; legacy ?asJson is untouched.
The website app gains `renderJson.sectionsToIgnore` (admin-configurable):
app-owned sections excluded by resolveType suffix — site-owned sections
should prefer `export const renderJson = false` in their own file.
Replaces the site-level wrapper pattern (handler + pages-loader fork) that
oficina-reserva ran as v1 — the default website/loaders/pages.ts now works
unchanged for renderJson consumers.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
renderJson is the replacement, not a sibling — consumers adopt ?renderJson directly (validation happens on PR previews, nothing in production speaks ?appJson). Only the legacy ?asJson remains as a separate, untouched mode. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Tagging OptionsShould a new tag be published when this PR is merged?
|
|
Superseded by #1613 — reopening from the oficina-dev org fork (org contribution, not my personal fork). |
What is this Contribution About?
Native
?renderJsonsupport in the website Fresh handler — the consumer side of the section-controlled JSON rendering introduced in deco-cx/deco#1208.website/handlers/fresh.ts: a native?renderJsonbranch (sibling of?asJson, withrenderJsontaking precedence, guarded by!isJsonOneShot). Serves the JSON projection produced by each section'srenderJsonexport via the runtime'sserializeResolvedSection/computeRenderCb.website/mod.ts: arenderJson.sectionsToIgnoreadmin prop so a site can override which sections are dropped from the JSON payload, instead of a hardcoded denylist.?appJsonalias —?renderJsonis its replacement. The standalone?asJsonmode is left untouched.Issue Link
Companion to the runtime feature — depends on it:
renderJsonexport,serializeResolvedSection,computeRenderCb,ResolvedSection,sectionModuleLookup,SerializeContext.Status / dependency
Important
Draft — blocked on deco-cx/deco#1208. This PR imports
computeRenderCb,serializeResolvedSection,ResolvedSection,sectionModuleLookupandSerializeContextfrom@deco/deco. Until #1208 is merged and published to JSR,deno task checkfails with 5×TS2305: has no exported member ...for those symbols.deno fmt --checkanddeno lintare clean.Test plan
deno fmt --checkcleandeno check— blocked on chore: clearsale api #1208 (5× TS2305 for the not-yet-published runtime exports)?asJsonand HTML byte-identical to baseline,?renderJsonmatches the runtime serialization, lazy fetch applies the per-section projection.Loom Video / Demonstration
Validated on the oficina-reserva storefront preview (pinned to the fork build). Loom/demo available on request.
🤖 Generated with Claude Code
Summary by cubic
Add native
?renderJsonto the website Fresh handler to return structured page JSON that honors each section’srenderJsonexport. Replaces the old?appJsonalias and adds a setting to ignore app-owned sections.New Features
?renderJsonendpoint that serializes sections via@deco/deco(computeRenderCb,serializeResolvedSection); takes precedence over?asJsonand disables async render for JSON responses.export const renderJson = falseand a newrenderJson.sectionsToIgnoreapp setting; skipped sections are not resolved or loaded.?appJsonalias.Dependencies
@deco/decoadded in feat(render): section-controlled JSON output via renderJson export deco#1208 (blocked until published).Written for commit a84e9f5. Summary will update on new commits.