From 3ec3b80b40be55e5d3b17029b1657f871bf3435e Mon Sep 17 00:00:00 2001 From: Viki Val Date: Mon, 14 Oct 2024 14:45:21 +0200 Subject: [PATCH] :zap: use Promise.all --- services/ipos/src/routes/pinning.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/ipos/src/routes/pinning.ts b/services/ipos/src/routes/pinning.ts index 112a537..3c6c263 100644 --- a/services/ipos/src/routes/pinning.ts +++ b/services/ipos/src/routes/pinning.ts @@ -91,11 +91,13 @@ app.post('/pinFile', vValidator('form', pinFileRequestSchema), async (c) => { }, }) + const promises: Promise[] = [] for (const { file } of files) { const path = `${cid}/${file.name}` - c.executionCtx.waitUntil(c.env.BUCKET.put(keyOf(path), file)) + promises.push(c.env.BUCKET.put(keyOf(path), file)) } + c.executionCtx.waitUntil(Promise.allSettled(promises)) } else { const { content, file: f } = files[0] cid = (await hashOf(content)).toV0().toString()