MCPcopy
hub / github.com/partykit/partykit / onBeforeRequest

Method onBeforeRequest

examples/class/src/server.ts:10–17  ·  view source on GitHub ↗
(req: Party.Request, lobby: Party.Lobby)

Source from the content-addressed store, hash-verified

8 // onBefore* handlers that run in the worker nearest the user are now
9 // explicitly marked static, because they have no access to Party state
10 static async onBeforeRequest(req: Party.Request, lobby: Party.Lobby) {
11 await lobby.parties.main.get(lobby.id).fetch("/foo");
12 await lobby.parties.main.get(lobby.id).fetch(req);
13
14 await lobby.parties.main.get(lobby.id).fetch(req.url, req);
15
16 return req;
17 }
18 static async onBeforeConnect(req: Party.Request) {
19 return req;
20 }

Callers 1

fetchFunction · 0.80

Calls 2

getMethod · 0.65
fetchMethod · 0.45

Tested by

no test coverage detected