MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / fetch

Function fetch

packages/player/tests/perf/server.ts:148–185  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

146 const server = Bun.serve({
147 port: options.port ?? 0,
148 async fetch(req) {
149 const url = new URL(req.url);
150 const path = url.pathname;
151
152 if (path === "/" || path === "/host.html") {
153 const fixture = url.searchParams.get("fixture") || "gsap-heavy";
154 const width = Number(url.searchParams.get("width") || "1920");
155 const height = Number(url.searchParams.get("height") || "1080");
156 const html = buildHostHtml(fixture, width, height);
157 return applyCacheHeaders(
158 new Response(html, { headers: { "Content-Type": "text/html; charset=utf-8" } }),
159 noCache,
160 );
161 }
162
163 if (path === "/player/hyperframes-player.global.js") {
164 return applyCacheHeaders(await readBunFile(PATHS.player), noCache);
165 }
166
167 if (path === "/vendor/hyperframe.runtime.iife.js") {
168 return applyCacheHeaders(await readBunFile(PATHS.runtime), noCache);
169 }
170
171 if (path === "/vendor/gsap.min.js") {
172 return applyCacheHeaders(await readBunFile(PATHS.gsap), noCache);
173 }
174
175 if (path.startsWith("/fixtures/")) {
176 const rel = path.replace(/^\/fixtures\//, "");
177 const filePath = join(PATHS.fixturesDir, rel);
178 if (!filePath.startsWith(PATHS.fixturesDir)) {
179 return new Response("Forbidden", { status: 403 });
180 }
181 return applyCacheHeaders(await readBunFile(filePath), noCache);
182 }
183
184 return new Response("Not found", { status: 404 });
185 },
186 });
187
188 // server.port is `number | undefined` in Bun's types (undefined only for unix-socket

Callers 15

lintMediaUrlsFunction · 0.85
StudioAppFunction · 0.85
AssetsTab.tsxFile · 0.85
useRenderQueueFunction · 0.85
probeSourceElementFunction · 0.85
FontFamilyFieldFunction · 0.85
importSystemFontFunction · 0.85
NLELayout.tsxFile · 0.85
flushEventsFunction · 0.85
addBlockToProjectFunction · 0.85
sendFunction · 0.85
useCaptionSyncFunction · 0.85

Calls 4

buildHostHtmlFunction · 0.85
applyCacheHeadersFunction · 0.85
readBunFileFunction · 0.85
getMethod · 0.80

Tested by 3

expectTextResponseFunction · 0.68
expectInjectedRenderFpsFunction · 0.68
expectRejectionFunction · 0.68