(requestPath: string)
| 614 | } |
| 615 | |
| 616 | async 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 | |
| 636 | async function readStudioAsset(fileName: string): Promise<Buffer | string> { |
| 637 | const triedPaths: string[] = [] |
no test coverage detected