-
Notifications
You must be signed in to change notification settings - Fork 15
/
factory.js
31 lines (26 loc) · 721 Bytes
/
factory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { S3Client, CreateBucketCommand, ListBucketsCommand, DeleteBucketCommand } from '@aws-sdk/client-s3'
const s3config = {
forcePathStyle: true,
region: "us-east-1",
}
const isLocal = process.env.IS_OFFLINE
if (isLocal) {
const host = process.env.LOCALSTACK_HOST || "localhost"
s3config.endpoint = `http://${host}:4566`
}
const s3Client = new S3Client(s3config)
const S3 = {
/** @param {ListBucketsCommandInput} args */
listBuckets: (args) => {
return s3Client.send(new ListBucketsCommand(args))
},
createBucket: (args) => {
return s3Client.send(new CreateBucketCommand(args))
},
deleteBucket: (args) => {
return s3Client.send(new DeleteBucketCommand(args))
}
}
export {
S3
}