
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Simple functional wrapper around S3 SDK to make most S3 interactions a single function call.
Nice sugarry layer over top of S3 to make utilizing it psuedo database-like a bit easier. Uses @aws-sdk library which is more moduarlized so your deploy sizes should be smaller.
In orderto do all the neat behaviors around an objet, we need a class to associate the configurations with.
@bucket(process.env.BUCKET_NAME)
class User {
@id
public id: string;
public name: string;
}
See the @mu-ts/serialization library for more control on how the object is serialized.
These are the commands you can use for interacting with an S3 bucket on a decorated object.
You can exclude the class if the object being persisted was created from a class.
import { putObject } from '@mu-ts/s3';
let user: User = new User();
user = await putObject(user);
If you created your object dreclty in JSON you will need to define the class used to persist.
import { putObject } from '@mu-ts/s3';
let user: User = { ... };
user = await putObject(user, User);
Load an object from S3 as an object.
import { getObject } from '@mu-ts/s3';
const user: User | undefined = await getObject(user, User);
If you want to return a specific version, you can specify that as well.
import { getObject } from '@mu-ts/s3';
const versionId: string = '...';
const user: User | undefined = await getObject(user, User, versionId);
Delete an object from S3. If a specific version is deleted (versioning enabled on bucket), then it is returned, undefined is returned otherwise.
import { deleteObject } from '@mu-ts/s3';
const versionId: string | undefined = await deleteObject(user, User);
If you want to delete a specific version, you can specify that as well.
import { getObject } from '@mu-ts/s3';
const versionId: string = '...';
const user: User | undefined = await deleteObject(user, User, versionId);
Load the metadata for an object, or get undefined if nothing is found.
import { headObject } from '@mu-ts/s3';
const metadata: Record<string, string> | undefined = await headObject(user, User);
Load the metadata for an object at a specific version, or get undefined if nothing is found.
import { getObject } from '@mu-ts/s3';
const versionId: string = '...';
const metadata: Record<string, string> | undefined = await headObject(user, User, versionId);
Get a boolean value for if an object exists. Uses headObject under the covers since its lighter weight than loading the whole object.
import { headObject } from '@mu-ts/s3';
const exists: boolean = await existsObject(user, User);
Load the metadata for an object at a specific version, or get undefined if nothing is found.
import { getObject } from '@mu-ts/s3';
const versionId: string = '...';
const exists: boolean = await existsObject(user, User, versionId);
Return a list of object metadata (key, etag, size, etc) for a bucket.
import { listObjects, Objects, ObjectKey } from '@mu-ts/s3';
const pageSize: number = 100;
const results: Objects = await listObjects(User, undefined, pageSize);
/**
* Continuation tokens are returned so pagination can continue.
*/
const continuationToken: string = results.getContinuationToken();
const results: ObjectKey[] = results.getResults();
const nextResults: Objects = await listObjects(User, undefined, pageSize, continuationToken);
FAQs
Simple functional wrapper around S3 SDK to make most S3 interactions a single function call.
We found that @mu-ts/s3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.