MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / fetch

Method fetch

apps/yalt/src/index.ts:145–173  ·  view source on GitHub ↗
(request: Request<unknown, CfProperties<unknown>>)

Source from the content-addressed store, hash-verified

143 ) {}
144
145 async fetch(request: Request<unknown, CfProperties<unknown>>): Promise<Response> {
146 const url = new URL(request.url);
147
148 switch (url.pathname) {
149 case '/connect': {
150 console.log(`Handling connect request`);
151
152 // This is a request from the client to connect to the tunnel
153 if (request.headers.get('Upgrade') !== 'websocket') {
154 return new Response('expected websocket', { status: 400 });
155 }
156
157 const pair = new WebSocketPair();
158 const [clientSocket, serverSocket] = Object.values(pair);
159
160 await this.handleSocket(serverSocket);
161
162 console.log(`Successfully connected to tunnel`);
163
164 return new Response(null, { status: 101, webSocket: clientSocket });
165 }
166 case '/api/trigger': {
167 return this.handleTunnelRequest(request);
168 }
169 default: {
170 return new Response('Not Found', { status: 404 });
171 }
172 }
173 }
174
175 private async handleSocket(socket: WebSocket) {
176 if (this.socket) {

Callers 4

fetchFunction · 0.80
uploadToObjectStoreFunction · 0.80
index.test.tsFile · 0.80
retries.tsFile · 0.80

Calls 4

handleSocketMethod · 0.95
handleTunnelRequestMethod · 0.95
logMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected