From c684c2f8f4e7e57d4d53dcd7be7f66ea14cdf120 Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Tue, 6 Aug 2024 15:56:40 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20s3client=20doesn't=20work=20insi?= =?UTF-8?q?de=20worker,=20removing=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/_common/grapherRenderer.ts | 56 ++++++++++++++-------------- functions/package.json | 1 - yarn.lock | 3 +- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/functions/_common/grapherRenderer.ts b/functions/_common/grapherRenderer.ts index f796331e992..fd0aa7a2c20 100644 --- a/functions/_common/grapherRenderer.ts +++ b/functions/_common/grapherRenderer.ts @@ -20,34 +20,34 @@ import { Env } from "../grapher/thumbnail/[slug].js" import { R2GrapherConfigDirectory } from "@ourworldindata/types" import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3" -async function getFileFromR2(key: string, env: Env): Promise { - const s3Client = new S3Client({ - endpoint: env.R2_ENDPOINT, - forcePathStyle: false, - region: env.R2_REGION, - credentials: { - accessKeyId: env.R2_ACCESS_KEY_ID, - secretAccessKey: env.R2_SECRET_ACCESS_KEY, - }, - }) - - const params = { - Bucket: env.GRAPHER_CONFIG_R2_BUCKET, - Key: key, - } - - try { - console.log("preparing s3 get") - const response = await s3Client.send(new GetObjectCommand(params)) - console.log("got s3 response") - const content = await response.Body.transformToString() - console.log("got s3 content") - return content - } catch (err) { - if (err.name === "NoSuchKey") return null - else throw err - } -} +// async function getFileFromR2(key: string, env: Env): Promise { +// const s3Client = new S3Client({ +// endpoint: env.R2_ENDPOINT, +// forcePathStyle: false, +// region: env.R2_REGION, +// credentials: { +// accessKeyId: env.R2_ACCESS_KEY_ID, +// secretAccessKey: env.R2_SECRET_ACCESS_KEY, +// }, +// }) + +// const params = { +// Bucket: env.GRAPHER_CONFIG_R2_BUCKET, +// Key: key, +// } + +// try { +// console.log("preparing s3 get") +// const response = await s3Client.send(new GetObjectCommand(params)) +// console.log("got s3 response") +// const content = await response.Body.transformToString() +// console.log("got s3 content") +// return content +// } catch (err) { +// if (err.name === "NoSuchKey") return null +// else throw err +// } +// } declare global { // eslint-disable-next-line no-var diff --git a/functions/package.json b/functions/package.json index a502e033715..ee9979ff2fa 100644 --- a/functions/package.json +++ b/functions/package.json @@ -1,7 +1,6 @@ { "name": "owid-functions", "dependencies": { - "@aws-sdk/client-s3": "3.572.0", "@ourworldindata/grapher": "workspace:^", "@ourworldindata/utils": "workspace:^", "itty-router": "^5.0.17", diff --git a/yarn.lock b/yarn.lock index f030d4d4fc0..811e04df0d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -425,7 +425,7 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/client-s3@npm:3.572.0, @aws-sdk/client-s3@npm:^3.572.0": +"@aws-sdk/client-s3@npm:^3.572.0": version: 3.572.0 resolution: "@aws-sdk/client-s3@npm:3.572.0" dependencies: @@ -15274,7 +15274,6 @@ __metadata: version: 0.0.0-use.local resolution: "owid-functions@workspace:functions" dependencies: - "@aws-sdk/client-s3": "npm:3.572.0" "@cloudflare/workers-types": "npm:^4.20240614.0" "@ourworldindata/grapher": "workspace:^" "@ourworldindata/utils": "workspace:^"