Created
November 11, 2021 06:18
-
-
Save JonnoFTW/4df407c39e57aad0510171e4cb703355 to your computer and use it in GitHub Desktop.
Somewhat saner aws sdk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const s3 = require('@aws-sdk/client-s3') | |
class SaneS3 { | |
constructor(...args) { | |
this.client = new s3.S3Client(...args) | |
} | |
} | |
Object.entries(s3).forEach((entry) => { | |
let [name, fn] = entry | |
if(['S3Client', 'S3'].includes(name)) { | |
return | |
} | |
// make its name camelCase instead of PascalCaseCommand | |
name = name[0].toLocaleLowerCase() + name.substring(1).replace(/Command$/, '') | |
SaneS3.prototype[name] = async function(...args) { | |
return this.client.send(new fn(...args)) | |
} | |
}) | |
const s4 = new SaneS3({ | |
accessKeyId: "access key", | |
secretAccessKey: "super secret key", | |
region: "us-east-1" | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment