Boots the actual workerd engine locally (miniflare devDep, no CF account needed) and round-trips HTTP (app.fetch) + WebSocket (WebSocketPair + app.upgrade) through edgeHandler's real request path, mirroring the Deno/Bun adapter tests' assertion shape. workerd's nodejs_compat genuinely does not implement node:http/node:https (confirmed in isolation against the real runtime; node:crypto, node:stream, node:net, node:tls, node:events, node:util, node:buffer all load fine under the same flags). The barrel statically imports them for the Node listen() path even though edgeHandler never touches it, so the bundler stubs those two modules at test-bundle time (inert createServer that throws if ever called) purely to let the worker load — edgeHandler itself is untouched. See project-docs/.superpowers/sdd/task-2-report.md for the full writeup and the suggested core follow-up (lazy-defer those imports behind listen()). Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
28 lines
740 B
TypeScript
28 lines
740 B
TypeScript
// Worker entry for the real workerd (Miniflare) integration test.
|
|
// Mirrors test/deno/ws.test.ts's graph so HTTP + WebSocket behavior is proven
|
|
// identically across runtimes. Run via `npm run test:edge` (see test/edge/run.ts).
|
|
import { createApp, Route, Get, Ws, ctx, Module } from '../../src/index';
|
|
import { edgeHandler } from '../../src/edge';
|
|
|
|
@Route('/rt')
|
|
class Rt {
|
|
@Get('/hello')
|
|
hello() {
|
|
return { ok: true };
|
|
}
|
|
|
|
@Ws('/echo')
|
|
echo(@ctx() { inbound }: any) {
|
|
return (async function* () {
|
|
for await (const msg of inbound) yield `echo:${msg}`;
|
|
})();
|
|
}
|
|
}
|
|
|
|
@Module({ mountpoint: '/', controllers: [Rt] })
|
|
class M {}
|
|
|
|
const app = createApp({ modules: [M] });
|
|
|
|
export default { fetch: edgeHandler(app) };
|