forked from probablycorey/baudy
Split 783-line src/server/index.tsx into: - src/server/audio.ts: ggwave init, playback, mic listener - src/server/game.ts: pure game logic, returns GuessResult - src/server/terminal.ts: console output, startup, handshake routing - src/pages/phone.tsx: Forge components + serialized client JS Phone page is fully standalone after load — all communication via ggwave audio (HELLO/HEY BUDDY handshake, guess responses). Added sendAndWait() for clean half-duplex request/response flow with configurable timeout. Server waits 500ms before replying to give phone time to switch to listening. Added TLS support for getUserMedia on mobile. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
778 B
TypeScript
33 lines
778 B
TypeScript
import { Hype } from '@because/hype'
|
|
import { PhonePage, stylesToCSS } from '../pages/phone'
|
|
import { startup } from './terminal'
|
|
|
|
const PORT = Number(process.env.PORT) || 3000
|
|
const app = new Hype({ layout: false, logging: false })
|
|
|
|
app.get('/ok', c => c.text('ok'))
|
|
|
|
app.get('/styles.css', c =>
|
|
c.text(stylesToCSS(), 200, { 'Content-Type': 'text/css; charset=utf-8' })
|
|
)
|
|
|
|
app.get('/', c => c.html(<PhonePage />))
|
|
|
|
app.get('/ggwave.js', () =>
|
|
new Response(Bun.file(new URL(import.meta.resolve('ggwave/ggwave.js')).pathname), {
|
|
headers: { 'Content-Type': 'application/javascript' },
|
|
})
|
|
)
|
|
|
|
startup(PORT)
|
|
|
|
export default {
|
|
...app.defaults,
|
|
port: PORT,
|
|
idleTimeout: 255,
|
|
tls: {
|
|
key: Bun.file('./certs/key.pem'),
|
|
cert: Bun.file('./certs/cert.pem'),
|
|
},
|
|
}
|