( c: Context<AppEnv>, path: string, notFoundMessage?: string, )
| 45 | }; |
| 46 | |
| 47 | export const getRegistryView = async ( |
| 48 | c: Context<AppEnv>, |
| 49 | path: string, |
| 50 | notFoundMessage?: string, |
| 51 | ): Promise<Response> => { |
| 52 | const revision = await getCurrentRevision(c); |
| 53 | const object = await c.env.REGISTRY.get(`snapshots/${revision}/api/${path}`, { |
| 54 | onlyIf: c.req.raw.headers, |
| 55 | }); |
| 56 | if (!object) { |
| 57 | if (notFoundMessage) { |
| 58 | throw notFound(notFoundMessage); |
| 59 | } |
| 60 | throw badGateway('Bad Gateway. Registry snapshot is incomplete.'); |
| 61 | } |
| 62 | |
| 63 | return respondWithObject( |
| 64 | object, |
| 65 | 'application/json; charset=utf-8', |
| 66 | CACHE_POLICIES.metadata, |
| 67 | ); |
| 68 | }; |
| 69 | |
| 70 | export const readRegistryView = async <T>( |
| 71 | c: Context<AppEnv>, |
no test coverage detected