Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

Reuse STS client (#5796)

authored by yoginth.com and committed by

GitHub 9bc82b9e a1c6bb7f

+16 -10
+3 -10
apps/api/src/routes/metadata/getSTS.ts
··· 1 - import { AssumeRoleCommand, STSClient } from "@aws-sdk/client-sts"; 2 - import { EVER_API, EVER_BUCKET, EVER_REGION } from "@hey/data/constants"; 1 + import { AssumeRoleCommand } from "@aws-sdk/client-sts"; 2 + import { EVER_BUCKET } from "@hey/data/constants"; 3 3 import type { Context } from "hono"; 4 4 import handleApiError from "src/utils/handleApiError"; 5 + import stsClient from "src/utils/stsClient"; 5 6 6 7 const params = { 7 8 DurationSeconds: 900, ··· 25 26 26 27 const getSTS = async (ctx: Context) => { 27 28 try { 28 - const stsClient = new STSClient({ 29 - credentials: { 30 - accessKeyId: process.env.EVER_ACCESS_KEY as string, 31 - secretAccessKey: process.env.EVER_ACCESS_SECRET as string 32 - }, 33 - endpoint: EVER_API, 34 - region: EVER_REGION 35 - }); 36 29 const command = new AssumeRoleCommand({ 37 30 ...params, 38 31 RoleArn: undefined,
+13
apps/api/src/utils/stsClient.ts
··· 1 + import { STSClient } from "@aws-sdk/client-sts"; 2 + import { EVER_API, EVER_REGION } from "@hey/data/constants"; 3 + 4 + const stsClient = new STSClient({ 5 + credentials: { 6 + accessKeyId: process.env.EVER_ACCESS_KEY as string, 7 + secretAccessKey: process.env.EVER_ACCESS_SECRET as string 8 + }, 9 + endpoint: EVER_API, 10 + region: EVER_REGION 11 + }); 12 + 13 + export default stsClient;