🎥 Make videos programmatically with React
get buckets API
Jonny Burger55d92c9ddf3e
diff --git a/packages/lambda/src/api/get-buckets.ts b/packages/lambda/src/api/get-buckets.tsindex 72b83d41f3..05df83266c 100644--- a/packages/lambda/src/api/get-buckets.ts+++ b/packages/lambda/src/api/get-buckets.ts@@ -10,17 +10,15 @@ export type BucketWithLocation = {region: AwsRegion;};-export const getRemotionS3Buckets = async (+export const getRemotionBuckets = async (region: AwsRegion,forceBucketName?: string,-): Promise<{- remotionBuckets: BucketWithLocation[];-}> => {+): Promise<BucketWithLocation[]> => {const {Buckets} = await getS3Client(region, null).send(new ListBucketsCommand({}),);if (!Buckets) {- return {remotionBuckets: []};+ return [];}const remotionBuckets = Buckets.filter((b) => {@@ -66,9 +64,8 @@ export const getRemotionS3Buckets = async (};}).filter((b) => b.region);- return {- remotionBuckets: bucketsWithLocation.filter((bucket) => {- return bucket.region === region;- }),- };++ return bucketsWithLocation.filter((bucket) => {+ return bucket.region === region;+ });};diff --git a/packages/lambda/src/api/get-or-create-bucket.ts b/packages/lambda/src/api/get-or-create-bucket.tsindex c953335e5c..f2d37ce62f 100644--- a/packages/lambda/src/api/get-or-create-bucket.ts+++ b/packages/lambda/src/api/get-or-create-bucket.ts@@ -4,7 +4,7 @@ import {REMOTION_BUCKET_PREFIX} from '../shared/constants';import {applyLifeCyleOperation} from '../shared/lifecycle-rules';import {makeBucketName} from '../shared/validate-bucketname';import {createBucket} from './create-bucket';-import {getRemotionS3Buckets} from './get-buckets';+import {getRemotionBuckets} from './get-buckets';type GetOrCreateBucketInputInner = {region: AwsRegion;@@ -26,7 +26,7 @@ export type GetOrCreateBucketOutput = {export const internalGetOrCreateBucket = async (params: GetOrCreateBucketInputInner,): Promise<GetOrCreateBucketOutput> => {- const {remotionBuckets} = await getRemotionS3Buckets(params.region);+ const remotionBuckets = await getRemotionBuckets(params.region);if (remotionBuckets.length > 1) {throw new Error(`You have multiple buckets (${remotionBuckets.map(diff --git a/packages/lambda/src/api/get-sites.ts b/packages/lambda/src/api/get-sites.tsindex 44ca605589..69719990a4 100644--- a/packages/lambda/src/api/get-sites.ts+++ b/packages/lambda/src/api/get-sites.ts@@ -4,7 +4,7 @@ import {getSitesKey} from '../shared/constants';import {getAccountId} from '../shared/get-account-id';import {makeS3ServeUrl} from '../shared/make-s3-url';import type {BucketWithLocation} from './get-buckets';-import {getRemotionS3Buckets} from './get-buckets';+import {getRemotionBuckets} from './get-buckets';type Site = {sizeInBytes: number;@@ -34,9 +34,9 @@ export const getSites = async ({region,forceBucketName,}: GetSitesInput): Promise<GetSitesOutput> => {- const {remotionBuckets} = forceBucketName- ? await getRemotionS3Buckets(region, forceBucketName)- : await getRemotionS3Buckets(region);+ const remotionBuckets = forceBucketName+ ? await getRemotionBuckets(region, forceBucketName)+ : await getRemotionBuckets(region);const accountId = await getAccountId({region});const sites: {[key: string]: Site} = {};diff --git a/packages/lambda/src/functions/aws-implementation.ts b/packages/lambda/src/functions/aws-implementation.tsindex 398a2ad0e0..ae175ff33e 100644--- a/packages/lambda/src/functions/aws-implementation.ts+++ b/packages/lambda/src/functions/aws-implementation.ts@@ -1,4 +1,5 @@import type {ProviderSpecifics} from '@remotion/serverless';+import {getRemotionBuckets} from '../api/get-buckets';import type {AwsRegion} from '../regions';import {getCurrentRegionInFunction} from './helpers/get-current-region';@@ -20,4 +21,5 @@ export const awsImplementation: ProviderSpecifics<AwsRegion> = {},getCurrentRegionInFunction,regionType: 'us-east-1',+ getBuckets: getRemotionBuckets,};diff --git a/packages/serverless/src/provider-implementation.ts b/packages/serverless/src/provider-implementation.tsindex a323a35432..773fd21675 100644--- a/packages/serverless/src/provider-implementation.ts+++ b/packages/serverless/src/provider-implementation.ts@@ -1,5 +1,17 @@+export type BucketWithLocation<Region extends string> = {+ name: string;+ creationDate: number;+ region: Region;+};++type GetBuckets<Region extends string> = (+ region: Region,+ forceBucketName?: string,+) => Promise<BucketWithLocation<Region>[]>;+export type ProviderSpecifics<Region extends string> = {getChromiumPath: () => string;getCurrentRegionInFunction: () => Region;regionType: Region;+ getBuckets: GetBuckets<Region>;};