MCPcopy
hub / github.com/prisma/prisma / serveStudioAsset

Function serveStudioAsset

packages/cli/src/Studio.ts:616–634  ·  view source on GitHub ↗
(requestPath: string)

Source from the content-addressed store, hash-verified

614}
615
616async function serveStudioAsset(requestPath: string): Promise<Response> {
617 const fileName = requestPath.substring(1)
618 const contentType = FILE_EXTENSION_TO_CONTENT_TYPE[extname(fileName)]
619
620 try {
621 return withCors(
622 new Response(await readStudioAsset(fileName), {
623 headers: { 'Content-Type': contentType },
624 status: 200,
625 }),
626 )
627 } catch (error: unknown) {
628 if (isNotFoundError(error)) {
629 return textResponse('Not Found', 404)
630 }
631
632 return textResponse('Internal Server Error', 500)
633 }
634}
635
636async function readStudioAsset(fileName: string): Promise<Buffer | string> {
637 const triedPaths: string[] = []

Callers 1

Calls 4

withCorsFunction · 0.85
readStudioAssetFunction · 0.85
isNotFoundErrorFunction · 0.85
textResponseFunction · 0.85

Tested by

no test coverage detected