MCPcopy
hub / github.com/partykit/partykit / onRequest

Function onRequest

examples/basic/src/server.ts:86–109  ·  view source on GitHub ↗
(req, room)

Source from the content-addressed store, hash-verified

84 },
85
86 async onRequest(req, room) {
87 console.log(room.env);
88
89 console.log(process.env.WHATUP);
90 console.log(room.context.parties);
91 const res = await room.context.parties.xyz.get("some-id").fetch();
92 console.log("gottt", await res.text());
93 const wssss = await room.context.parties.xyz.get("some-id").socket();
94 wssss.addEventListener("message", (evt) => {
95 console.log("got a message from xyz", evt.data);
96 });
97
98 console.log(SOME_GLOBAL);
99 return new Response(
100 "Hello world:" +
101 req.headers.get("x-foo") +
102 " " +
103 room.id +
104 " " +
105 TEST_DEFINE_NUMBER +
106 " " +
107 PARTYKIT_HOST
108 );
109 },
110
111 onCron(cron: Cron, _lobby, _ctx) {
112 console.log(

Callers

nothing calls this directly

Calls 2

getMethod · 0.65
fetchMethod · 0.45

Tested by

no test coverage detected