async hydrate()

in src/commands/image/get.ts [34:55]


  async hydrate(image: any) {
    const asTuples = Object.entries(image)
    const hydrated = asTuples.map(async ([key, value]) => {
      try {
        if (typeof value !== 'object' || Object.keys(value!).length > 1) {
          return [key, value]
        }

        if (!value || !('uri' in value)) {
          return [key, value]
        }

        const { uri } = value as { uri: string }
        const response = await this.http!.get(new URL(uri))
        const { data } = await response.json()
        return [key, { ...value, data }]
      } catch {
        return [key, value]
      }
    })
    return Object.fromEntries(await Promise.all(hydrated))
  }