Skip to content

Instantly share code, notes, and snippets.

@JonnoFTW
Created November 11, 2021 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonnoFTW/4df407c39e57aad0510171e4cb703355 to your computer and use it in GitHub Desktop.
Save JonnoFTW/4df407c39e57aad0510171e4cb703355 to your computer and use it in GitHub Desktop.
Somewhat saner aws sdk
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