Skip to content

fix examples: http-server and websocket#91

Merged
cs01 merged 11 commits intomainfrom
worktree-fix-examples
Mar 5, 2026
Merged

fix examples: http-server and websocket#91
cs01 merged 11 commits intomainfrom
worktree-fix-examples

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 5, 2026

fix examples: http-server and websocket

Summary

  • http-server: replace raw JSON strings with c.json() object literals; serve an embedded HTML homepage with clickable routes and inline POST forms
  • websocket: fix crash on open (removed wsBroadcast call on connect), iMessage-style chat UI (white/blue bubbles, sender names, arrow button), client-generated IDs, structured sender|text message protocol, fixed status var shadowing window.status, constrained container width on wide screens
  • http redirect fixes: set hasHeaders=true when handler returns HttpResponse from .d.ts; use embedDir not embedFile for getEmbeddedFile lookup

Changes

examples/http-server.ts

  • All c.json() calls now pass object literals instead of raw JSON strings
  • Root route serves embedded index.html (HTML homepage with all routes)
  • New examples/http-server-public/index.html with clickable GET links and inline POST forms

examples/websocket/

  • app.ts: remove wsBroadcast on open (caused crash), structured sender|text protocol, removed redundant interface definitions (use .d.ts)
  • public/chat.js: client-generated UUID, parse structured messages, distinguish sent/received sides
  • public/style.css: iMessage-style bubbles, full-screen layout, constrained width

src/codegen/llvm-generator.ts

  • Support embedDir for embedded file lookup (fixes blank page on redirect)

Test plan

  • node dist/chad-node.js run examples/http-server.ts — homepage loads, all routes return JSON
  • node dist/chad-node.js run examples/websocket/app.ts — chat UI loads, messages appear with correct sender/receiver styling, user count updates on leave
  • Multiple browser tabs — broadcast works, leave message shown to remaining users
  • bash scripts/run-examples.sh — all 9 example tests pass

@cs01 cs01 changed the title fix examples fix examples: http-server and websocket Mar 5, 2026
@cs01 cs01 merged commit df8ff7c into main Mar 5, 2026
12 checks passed
@cs01 cs01 deleted the worktree-fix-examples branch March 5, 2026 06:59
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.

1 participant