MCPcopy Create free account
hub / github.com/CopilotKit/aimock / handleVideoStatus

Function handleVideoStatus

src/video.ts:368–435  ·  view source on GitHub ↗
(
  req: http.IncomingMessage,
  res: http.ServerResponse,
  videoId: string,
  journal: Journal,
  defaults: HandlerDefaults,
  setCorsHeaders: (res: http.ServerResponse) => void,
  videoStates: VideoStateMap,
)

Source from the content-addressed store, hash-verified

366}
367
368export function handleVideoStatus(
369 req: http.IncomingMessage,
370 res: http.ServerResponse,
371 videoId: string,
372 journal: Journal,
373 defaults: HandlerDefaults,
374 setCorsHeaders: (res: http.ServerResponse) => void,
375 videoStates: VideoStateMap,
376): void {
377 setCorsHeaders(res);
378 const path = req.url ?? `/v1/videos/${videoId}`;
379 const method = req.method ?? "GET";
380
381 if (
382 applyChaos(
383 res,
384 null,
385 defaults.chaos,
386 req.headers,
387 journal,
388 { method, path, headers: flattenHeaders(req.headers), body: null },
389 "internal",
390 defaults.registry,
391 defaults.logger,
392 )
393 )
394 return;
395
396 const testId = getTestId(req);
397 const stateKey = `${testId}:${videoId}`;
398 const entry = videoStates.getEntry(stateKey);
399
400 if (!entry) {
401 journal.add({
402 method,
403 path,
404 headers: flattenHeaders(req.headers),
405 body: null,
406 response: { status: 404, fixture: null },
407 });
408 writeErrorResponse(
409 res,
410 404,
411 JSON.stringify({ error: { message: `Video ${videoId} not found`, type: "not_found" } }),
412 );
413 return;
414 }
415
416 const { video, createdAtUnix: created_at } = entry;
417
418 journal.add({
419 method,
420 path,
421 headers: flattenHeaders(req.headers),
422 body: null,
423 response: { status: 200, fixture: null },
424 });
425

Callers 1

handleGrokVideoStatusFunction · 0.85

Calls 8

setCorsHeadersFunction · 0.85
applyChaosFunction · 0.85
flattenHeadersFunction · 0.85
getTestIdFunction · 0.85
writeErrorResponseFunction · 0.85
getEntryMethod · 0.80
addMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…